{"record":{"id":"3a76f52b5c726298","repo":"Tencent/WeKnora","slug":"resource-not-found-3a76f5","errorCode":null,"errorMessage":"resource not found","messagePattern":"resource not found","errorType":"exception","errorClass":null,"httpStatus":null,"severity":"error","filePath":"internal/application/service/resource.go","lineNumber":122,"sourceCode":"\t\texisting, lookupErr := s.repo.GetByTenantLocation(ctx, tenantID, locationHash)\n\t\tif lookupErr == nil && existing != nil {\n\t\t\treturn types.BuildResourcePath(existing.Handle), nil\n\t\t}\n\t}\n\treturn \"\", fmt.Errorf(\"failed to allocate unique resource handle\")\n}\n\nfunc (s *resourceCatalog) Resolve(ctx context.Context, reference string) (*types.StoredResource, error) {\n\thandle, ok := types.ParseResourcePath(reference)\n\tif !ok {\n\t\treturn nil, fmt.Errorf(\"invalid resource reference\")\n\t}\n\tresource, err := s.repo.GetByHandle(ctx, handle)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\tif resource == nil {\n\t\treturn nil, fmt.Errorf(\"resource not found\")\n\t}\n\treturn resource, nil\n}\n\nfunc (s *resourceCatalog) ResolvePath(ctx context.Context, value string) (string, *types.StoredResource, error) {\n\tif _, ok := types.ParseResourcePath(value); !ok {\n\t\treturn value, nil, nil\n\t}\n\tresource, err := s.Resolve(ctx, value)\n\tif err != nil {\n\t\treturn \"\", nil, err\n\t}\n\treturn resource.PhysicalPath, resource, nil\n}\n\nfunc (s *resourceCatalog) Bind(ctx context.Context, reference, ownerType, ownerID, relation string) error {\n\tresource, err := s.Resolve(ctx, reference)\n\tif err != nil {","sourceCodeStart":104,"sourceCodeEnd":140,"githubUrl":"https://github.com/Tencent/WeKnora/blob/988cbb03305e055d8ebb7d46d9ac6cc0803cd074/internal/application/service/resource.go#L104-L140","documentation":"Resolve parsed a syntactically valid handle and queried the repo, but GetByHandle returned nil: no resource row with that handle exists (for the requesting context). This distinguishes a well-formed but unknown reference from a malformed one (error 551).","triggerScenarios":"Resolving a handle after the resource was deleted/MarkDeleted, using a handle from another tenant's catalog, or a typo'd/stale handle persisted by a caller.","commonSituations":"Cached references outliving the resource lifecycle; cross-environment handles (staging handle used in prod); callers not handling MarkDeleted cleanup.","solutions":["Confirm the resource still exists via the registration API or direct repo lookup before resolving","Check tenant/context scoping — the handle may exist under a different tenant","Treat as expected miss: fall back to re-Register or return a 404-equivalent to the end user","Purge caches of references when resources are deleted"],"exampleFix":"// before\nres, err := catalog.Resolve(ctx, ref)\nif err != nil { return err }\n// after\nres, err := catalog.Resolve(ctx, ref)\nif err != nil && strings.Contains(err.Error(), \"resource not found\") {\n    return ErrNotFound // surface as user-facing not-found, not a 500\n}","handlingStrategy":"fallback","validationCode":"_ = resource // no cheap pre-check exists; handle existence is only knowable via the repo","typeGuard":"func resourceExists(r *types.StoredResource) bool { return r != nil }","tryCatchPattern":"res, err := catalog.Resolve(ctx, ref)\nif err != nil && strings.Contains(err.Error(), \"resource not found\") {\n    return ErrNotFound // treat as expected miss, not a 500\n}","preventionTips":["Invalidate caches of resource references on delete/MarkDeleted","Never share handles across tenants/environments","Resolve immediately after Register rather than storing long-lived handles when possible","Return 404 semantics to end users for this specific error"],"tags":["not-found","resource-catalog"],"backgroundTag":"resource-not-found","analyzedSha":"988cbb03305e055d8ebb7d46d9ac6cc0803cd074","analyzedAt":"2026-09-02T14:41:08.344Z","contentChangedAt":null,"schemaVersion":2},"datasetVersion":"2026-09-08T10:18:20.063Z"}