{"record":{"id":"97b43d6e88f17569","repo":"Tencent/WeKnora","slug":"tenant-not-found","errorCode":null,"errorMessage":"tenant not found","messagePattern":"tenant not found","errorType":"error_code","errorClass":null,"httpStatus":404,"severity":"error","filePath":"internal/application/repository/tenant.go","lineNumber":15,"sourceCode":"package repository\n\nimport (\n\t\"context\"\n\t\"errors\"\n\n\t\"github.com/Tencent/WeKnora/internal/logger\"\n\t\"github.com/Tencent/WeKnora/internal/types\"\n\t\"github.com/Tencent/WeKnora/internal/types/interfaces\"\n\t\"gorm.io/gorm\"\n\t\"gorm.io/gorm/clause\"\n)\n\nvar (\n\tErrTenantNotFound         = errors.New(\"tenant not found\")\n\tErrTenantHasKnowledgeBase = errors.New(\"tenant has associated knowledge bases\")\n)\n\n// tenantRepository implements tenant repository interface\ntype tenantRepository struct {\n\tdb *gorm.DB\n}\n\n// NewTenantRepository creates a new tenant repository\nfunc NewTenantRepository(db *gorm.DB) interfaces.TenantRepository {\n\treturn &tenantRepository{db: db}\n}\n\n// CreateTenant creates tenant\nfunc (r *tenantRepository) CreateTenant(ctx context.Context, tenant *types.Tenant) error {\n\treturn r.db.WithContext(ctx).Create(tenant).Error\n}\n","sourceCodeStart":1,"sourceCodeEnd":33,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/repository/tenant.go#L1-L33","documentation":"Sentinel ErrTenantNotFound returned by tenant repository getters when GORM reports gorm.ErrRecordNotFound for the given tenant id — the id was valid syntactically but no tenant row exists (deleted or never created). It is a mapped not-found, not a DB error.","triggerScenarios":"Thrown at internal/application/repository/tenant.go:15 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Verify the tenant id in the request/auth context is correct and still exists","Create the tenant first, or return 404 to the caller instead of retrying"],"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"}