Tencent/WeKnora · error
bind copied resource: %w
Error message
bind copied resource: %w
What it means
In CopyFile, after the copy is stored and registered, an optional knowledgeID triggers catalog.Bind to attach the copied resource to a knowledge entry. On Bind failure the newly copied resource is deleted (rollback) and this wrapped error is returned. The copy is fully discarded; retry the entire CopyFile.
Source
Thrown at internal/application/service/file/resource_catalog.go:188
tenantID uint64,
knowledgeID string,
) (string, error) {
physical, _, err := s.resolve(ctx, filePath)
if err != nil {
return "", err
}
copied, err := s.inner.CopyFile(ctx, physical, tenantID, knowledgeID)
if err != nil {
return "", err
}
ref, err := s.register(ctx, copied, tenantID, filepath.Base(physical), 0, false, "")
if err != nil {
return "", err
}
if knowledgeID != "" {
if err := s.catalog.Bind(ctx, ref, types.ResourceOwnerKnowledge, knowledgeID, types.ResourceRelationSourceFile); err != nil {
_ = s.DeleteFile(ctx, ref)
return "", fmt.Errorf("bind copied resource: %w", err)
}
}
return ref, nil
}
var _ interfaces.FileService = (*resourceCatalogFileService)(nil)
View on GitHub (pinned to 988cbb0330)
Solutions
- Validate the knowledgeID exists before CopyFile
- Read the wrapped error for the DB-level cause
- Retry the whole CopyFile — the rolled-back copy leaves no orphans
- Skip binding (empty knowledgeID) if the link is optional
Defensive patterns
Strategy: validation
Validate before calling
if knowledgeID != "" && !catalog.KnowledgeExists(ctx, knowledgeID) {
return fmt.Errorf("knowledge %q does not exist", knowledgeID)
} Try / catch
ref, err := svc.CopyFile(ctx, src, knowledgeID)
if err != nil && strings.Contains(err.Error(), "bind copied resource") {
// copy was rolled back; re-validate knowledgeID and retry the copy
} Prevention
- Validate the target knowledge entry before copying
- Serialize copy operations against knowledge deletions
- Treat the whole CopyFile as the retry unit
- Return/refresh knowledge IDs rather than reusing stale ones
When it happens
Trigger: Calling CopyFile with a non-empty knowledgeID where the knowledge entry is missing, concurrently deleted, or the catalog DB insert fails (constraint, connection loss).
Common situations: Copying files into knowledge bases that were deleted in another session, DB deadlocks/constraints during bulk copies, stale client-side knowledge IDs.
Related errors
- bind stored resource: %w
- local file service cannot copy %q: %w
- invalid source path: %w
- obs copy rejected source %q: %w
- failed to copy file in OBS: %w
AI-assisted analysis of Tencent/WeKnora@988cbb0330 (2026-09-02).
Data as JSON: /api/errors/f32665d10c5bf6cf.
Report an issue: GitHub.