{"record":{"id":"d59c31a619dabc07","repo":"Tencent/WeKnora","slug":"tenant-api-key-not-found","errorCode":null,"errorMessage":"tenant api key not found","messagePattern":"tenant api key not found","errorType":"error_code","errorClass":null,"httpStatus":404,"severity":"error","filePath":"internal/application/repository/tenant_api_key.go","lineNumber":13,"sourceCode":"package repository\n\nimport (\n\t\"context\"\n\t\"errors\"\n\t\"time\"\n\n\t\"github.com/Tencent/WeKnora/internal/types\"\n\t\"github.com/Tencent/WeKnora/internal/types/interfaces\"\n\t\"gorm.io/gorm\"\n)\n\nvar ErrTenantAPIKeyNotFound = errors.New(\"tenant api key not found\")\n\ntype tenantAPIKeyRepository struct {\n\tdb *gorm.DB\n}\n\nfunc NewTenantAPIKeyRepository(db *gorm.DB) interfaces.TenantAPIKeyRepository {\n\treturn &tenantAPIKeyRepository{db: db}\n}\n\nfunc (r *tenantAPIKeyRepository) CreateAPIKey(ctx context.Context, key *types.TenantAPIKey) error {\n\treturn r.db.WithContext(ctx).Create(key).Error\n}\n\nfunc (r *tenantAPIKeyRepository) GetAPIKeyByHash(ctx context.Context, hash string) (*types.TenantAPIKey, error) {\n\tvar key types.TenantAPIKey\n\terr := r.db.WithContext(ctx).Session(&gorm.Session{SkipHooks: true}).\n\t\tWhere(\"key_hash = ?\", hash).\n\t\tFirst(&key).Error","sourceCodeStart":1,"sourceCodeEnd":31,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/repository/tenant_api_key.go#L1-L31","documentation":"Sentinel ErrTenantAPIKeyNotFound: the tenant API-key repository looked up a key by id/value (or attempted an update/delete) and no matching row exists — either gorm.ErrRecordNotFound was mapped or the UPDATE affected 0 rows. Indicates a stale, revoked, or wrong key reference.","triggerScenarios":"Thrown at internal/application/repository/tenant_api_key.go:13 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the API key id/value; regenerate a key if it was deleted or rotated","Treat as 404 in the handler; do not retry the same key reference"],"exampleFix":null,"handlingStrategy":"type-guard","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"}