{"record":{"id":"b6374624d47bf031","repo":"Tencent/WeKnora","slug":"not-a-refresh-token","errorCode":null,"errorMessage":"not a refresh token","messagePattern":"not a refresh token","errorType":"validation","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/user.go","lineNumber":1350,"sourceCode":"\t}\n\n\ttokenType, ok := claims[\"type\"].(string)\n\tif !ok || tokenType != \"refresh\" {\n\t\treturn \"\", \"\", errors.New(\"not a refresh token\")\n\t}\n\n\tuserID, ok := claims[\"user_id\"].(string)\n\tif !ok {\n\t\treturn \"\", \"\", errors.New(\"invalid user ID in token\")\n\t}\n\n\t// Check if token is revoked\n\ttokenRecord, err := s.tokenRepo.GetTokenByValue(ctx, refreshTokenString)\n\tif err != nil || tokenRecord == nil || tokenRecord.IsRevoked {\n\t\treturn \"\", \"\", errors.New(\"refresh token is revoked\")\n\t}\n\tif tokenRecord.TokenType != \"refresh_token\" {\n\t\treturn \"\", \"\", errors.New(\"not a refresh token\")\n\t}\n\n\t// Get user\n\tuser, err := s.userRepo.GetUserByID(ctx, userID)\n\tif err != nil {\n\t\treturn \"\", \"\", err\n\t}\n\n\t// Revoke old refresh token\n\ttokenRecord.IsRevoked = true\n\t_ = s.tokenRepo.UpdateToken(ctx, tokenRecord)\n\n\t// Generate new tokens\n\treturn s.GenerateTokens(ctx, user)\n}\n\n// Logout invalidates every outstanding session for the user identified by\n// the presented JWT. Access and refresh tokens are both accepted so clients","sourceCodeStart":1332,"sourceCodeEnd":1368,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/user.go#L1332-L1368","documentation":"Raised in RefreshToken when the JWT type claim is not \"refresh\" or the stored record's TokenType is not \"refresh_token\" — an access token or wrong token kind was submitted to the refresh endpoint. Token-kind validation guard.","triggerScenarios":"Thrown at internal/application/service/user.go:1350 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Send the refresh token, not the access token, to the refresh endpoint","Check the client's token storage so it does not confuse token kinds"],"exampleFix":null,"handlingStrategy":"validation","validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}