{"record":{"id":"83fe132eb9ec226d","repo":"crowdsecurity/crowdsec","slug":"unable-to-parse-jwt-expiration-w","errorCode":null,"errorMessage":"unable to parse jwt expiration: %w","messagePattern":"unable to parse jwt expiration: %w","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"pkg/apiclient/auth_jwt.go","lineNumber":135,"sourceCode":"\tdefer resp.Body.Close()\n\n\tif resp.StatusCode < 200 || resp.StatusCode >= 300 {\n\t\tlog.Debugf(\"received response status %q when fetching %v\", resp.Status, req.URL)\n\n\t\terr = CheckResponse(resp)\n\t\tif err != nil {\n\t\t\treturn err\n\t\t}\n\t}\n\n\tvar response models.WatcherAuthResponse\n\n\tif err := json.NewDecoder(resp.Body).Decode(&response); err != nil {\n\t\treturn fmt.Errorf(\"unable to decode response: %w\", err)\n\t}\n\n\tif err := t.Expiration.UnmarshalText([]byte(response.Expire)); err != nil {\n\t\treturn fmt.Errorf(\"unable to parse jwt expiration: %w\", err)\n\t}\n\n\tt.Token = response.Token\n\n\tif t.TokenSave != nil {\n\t\terr = t.TokenSave(ctx, t.Token)\n\t\tif err != nil {\n\t\t\tlog.Errorf(\"unable to save token: %s\", err)\n\t\t}\n\t}\n\n\tlog.Debugf(\"token %s will expire on %s\", t.Token, t.Expiration.String())\n\n\tselect {\n\tcase t.TokenRefreshChan <- struct{}{}:\n\tdefault:\n\t\t// Do not block if no one is waiting for the token refresh (ie, PAPI fully disabled)\n\t}","sourceCodeStart":117,"sourceCodeEnd":153,"githubUrl":"https://github.com/crowdsecurity/crowdsec/blob/909b5157986a2b2c2163300fdaef5ed01289f7d2/pkg/apiclient/auth_jwt.go#L117-L153","documentation":"refreshJwtToken parses the 'expire' field of the auth response into the token expiration; the timestamp string from the API could not be parsed, so token validity tracking fails and the refresh is aborted.","triggerScenarios":"Thrown at pkg/apiclient/auth_jwt.go:135 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Check LAPI version compatibility with the client","Inspect the raw auth-jwt response in trace logs","Report a bug if LAPI is stock and up to date"],"exampleFix":null,"handlingStrategy":"fallback","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"909b5157986a2b2c2163300fdaef5ed01289f7d2","analyzedAt":"2026-09-06T12:27:26.012Z","contentChangedAt":"2026-09-06T12:27:26.012Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}