Tencent/WeKnora · error
resource not found
Error message
resource not found
What it means
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).
Source
Thrown at internal/application/service/resource.go:122
existing, lookupErr := s.repo.GetByTenantLocation(ctx, tenantID, locationHash)
if lookupErr == nil && existing != nil {
return types.BuildResourcePath(existing.Handle), nil
}
}
return "", fmt.Errorf("failed to allocate unique resource handle")
}
func (s *resourceCatalog) Resolve(ctx context.Context, reference string) (*types.StoredResource, error) {
handle, ok := types.ParseResourcePath(reference)
if !ok {
return nil, fmt.Errorf("invalid resource reference")
}
resource, err := s.repo.GetByHandle(ctx, handle)
if err != nil {
return nil, err
}
if resource == nil {
return nil, fmt.Errorf("resource not found")
}
return resource, nil
}
func (s *resourceCatalog) ResolvePath(ctx context.Context, value string) (string, *types.StoredResource, error) {
if _, ok := types.ParseResourcePath(value); !ok {
return value, nil, nil
}
resource, err := s.Resolve(ctx, value)
if err != nil {
return "", nil, err
}
return resource.PhysicalPath, resource, nil
}
func (s *resourceCatalog) Bind(ctx context.Context, reference, ownerType, ownerID, relation string) error {
resource, err := s.Resolve(ctx, reference)
if err != nil {View on GitHub (pinned to 988cbb0330)
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
Example fix
// before
res, err := catalog.Resolve(ctx, ref)
if err != nil { return err }
// after
res, err := catalog.Resolve(ctx, ref)
if err != nil && strings.Contains(err.Error(), "resource not found") {
return ErrNotFound // surface as user-facing not-found, not a 500
} Defensive patterns
Strategy: fallback
Validate before calling
_ = resource // no cheap pre-check exists; handle existence is only knowable via the repo
Type guard
func resourceExists(r *types.StoredResource) bool { return r != nil } Try / catch
res, err := catalog.Resolve(ctx, ref)
if err != nil && strings.Contains(err.Error(), "resource not found") {
return ErrNotFound // treat as expected miss, not a 500
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Cached references outliving the resource lifecycle; cross-environment handles (staging handle used in prod); callers not handling MarkDeleted cleanup.
Understand the failure class
Background: 'Could not be found', 'does not exist', 'not found in database': the resource-not-found family when an ID, slug, key, or URI lookup comes back empty — this error's family across 20 libraries.
Related errors
- join request not found
- rbac: resource not found
- knowledge service returned an empty result
- %w: %s
- mcp service not found
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/3a76f52b5c726298.
Report an issue: GitHub.