Skip to content

fix(uploads): manual file uploads must ignore provenance stamping - #6314

Merged
icecrasher321 merged 11 commits into
stagingfrom
fix/attachments
Aug 6, 2026
Merged

fix(uploads): manual file uploads must ignore provenance stamping#6314
icecrasher321 merged 11 commits into
stagingfrom
fix/attachments

Conversation

@icecrasher321

Copy link
Copy Markdown
Collaborator

Summary

Manual uploads don't have provenance markers. They're user generated.

Type of Change

  • Bug fix

Testing

Tested manually

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing
  • No new warnings introduced
  • I confirm that I have read and agree to the terms outlined in the Contributor License Agreement (CLA)

@vercel

vercel Bot commented Aug 6, 2026

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

1 Skipped Deployment
Project Deployment Actions Updated (UTC)
docs Skipped Skipped Aug 6, 2026 7:05am

Request Review

@cursor

cursor Bot commented Aug 6, 2026

Copy link
Copy Markdown

PR Summary

Medium Risk
Changes secret provenance classification for knowledge writes and Copilot attachment handling—incorrect behavior could block legitimate uploads or allow unsafe model input; scope is bounded by extensive new tests.

Overview
Treats headerless external knowledge writes (session/API key) as user-generated content with exact-empty durable provenance, while headerless internal workflow writes still skip provenance stamping unless a verified private envelope is present. External callers that submit a private provenance bundle are rejected.

Tag-definition delete routes now map KnowledgeTagProvenanceConflictError to 409 instead of a generic 500.

Copilot no longer silently drops attachments when upload tracking or workspace-file provenance verification fails—the chat payload throws on prepare errors, and the lifecycle aborts with a projection error instead of continuing without files. Tests cover successful attachment context and the new failure paths.

The agent handler normalizes workspace-picker file objects (serve URL + key) before hydration and provider execution so manual picks match the expected attachment shape.

Reviewed by Cursor Bugbot for commit f4f2e71. Configure here.

@greptile-apps

greptile-apps Bot commented Aug 6, 2026

Copy link
Copy Markdown
Contributor

Greptile Summary

This PR separates manual-upload metadata binding from secret-provenance classification and makes provenance lookup failures fail closed.

  • Preserves upload provenance when associating files with Copilot chats.
  • Classifies model attachments using canonical active storage keys rather than runtime attachment IDs.
  • Normalizes persisted workspace-picker files before provider execution.
  • Returns explicit errors when attachment provenance cannot be verified.
  • Accounts for database timestamp precision when binding provenance to a content version.

Confidence Score: 5/5

The PR appears safe to merge with no concrete blocking or independently actionable non-blocking issues identified.

The changed upload paths preserve provenance established during registration, canonical keys remain workspace-scoped and uniquely bound to active records, and verification failures now stop attachments before model execution.

Important Files Changed

Filename Overview
apps/sim/lib/uploads/contexts/workspace/workspace-file-secret-provenance.ts Uses canonical active storage keys for model-safety classification and binds provenance within the database timestamp's JavaScript-visible millisecond.
apps/sim/lib/uploads/contexts/workspace/workspace-file-manager.ts Makes chat upload tracking metadata-only so it preserves provenance established when user-uploaded bytes were registered.
apps/sim/lib/copilot/chat/payload.ts Stops Copilot payload construction with a user-facing error when an authorized attachment cannot be prepared.
apps/sim/lib/copilot/request/lifecycle/run.ts Fails closed when initial attachment provenance cannot be verified rather than silently continuing without files.
apps/sim/providers/index.ts Prevents provider execution when attachment provenance lookup fails.
apps/sim/executor/handlers/agent/agent-handler.test.ts Adds coverage for normalizing and hydrating persisted workspace-picker file metadata.

Sequence Diagram

sequenceDiagram
  participant User
  participant Upload as Upload Registration
  participant DB as Workspace Files
  participant Chat as Chat Binding
  participant Filter as Provenance Filter
  participant Model

  User->>Upload: Upload file bytes
  Upload->>DB: Store file and initial provenance
  User->>Chat: Attach file to chat
  Chat->>DB: Update chat metadata only
  Chat->>Filter: Submit canonical storage key
  Filter->>DB: Load active row and provenance
  alt Provenance is model-safe
    Filter->>Model: Include attachment
  else Unsafe or unknown
    Filter-->>Chat: Reject or omit attachment
  else Lookup fails
    Filter-->>Chat: Fail request explicitly
  end
Loading

Reviews (1): Last reviewed commit: "fix(uploads): manual uploads provenance ..." | Re-trigger Greptile

@icecrasher321

Copy link
Copy Markdown
Collaborator Author

bugbot run

Comment thread apps/sim/lib/knowledge/documents/document-processor.ts
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

bugbot run

Comment thread apps/sim/lib/uploads/server/metadata.ts
@icecrasher321

Copy link
Copy Markdown
Collaborator Author

bugbot run

@cursor cursor Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

✅ Bugbot reviewed your changes and found no new issues!

Comment @cursor review or bugbot run to trigger another review on this PR

Reviewed by Cursor Bugbot for commit f4f2e71. Configure here.

@icecrasher321
icecrasher321 merged commit 377702f into staging Aug 6, 2026
29 checks passed
@icecrasher321
icecrasher321 deleted the fix/attachments branch August 6, 2026 07:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant