Skip to content

fix(workflow-code): name workspace files by path in file() references - #10545

Merged
waleedlatif1 merged 5 commits into
stagingfrom
fix/wac-qa-b3-file-references
Dec 1, 2026
Merged

waleedlatif1 merged 5 commits into
stagingfrom
fix/wac-qa-b3-file-references

Conversation

@waleedlatif1

@waleedlatif1 waleedlatif1 commented Dec 1, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

  • The documented form was refused. The SDK and docs say file('contracts/acme.pdf'), but the server resolved file keys through resource-key slugs (a-txt-2) that nothing listed. file('<folder>/<name>') now resolves the workspace file at that path. That is the key the workspace directory already gives a file under files/<path>. Files no longer get key rows.
  • The form that applied failed at run time. Materialize wrote the wf_… file id into the upload object's key, which the runtime reads as a storage key, so runs failed with "File is required". A file('<path>') value now materializes the object the editor's workspace file picker stores: name, serve path, storage key, size, type, file id and folder path (new ResourceKeyResolver.uploadOf).
  • The stored value never printed back. Canonicalize now lifts a stored file-upload object to file('<path>') when its id names a live workspace file, or its storage key does when it has no id. Files uploaded in place stay verbatim objects. An unchanged re-apply keeps the stored bytes. --to promotion resolves the target workspace's own file at the same path.
  • Nothing listed file keys. The v2 source resources manifest gains files (paths, gated by files.use like the Files tab). workspace.d.ts types those paths as FileKey, plus the paths the directory holds under files/. file() is now file<K extends FileKey>. File-upload fields accept FileRef or a list of them, and UploadedFile.key is a plain string again.
  • The docs disagreed. syntax.mdx, SYNTAX.md, workspace-code/DESIGN.md, the directory guide, catalog/types.ts and the model.ts encoding note now describe the path form.
  • Cleanup. Removed the file resource-key claim on create and the withinCreate hook that only that claim used. A create's pending entry is keyed by its path, so a workflow in the same apply still dry-runs, and the commit re-plans against the written file.
  • Risks.
    • An upload object written through the broken form (a wf_… id in key) now prints as file('<path>'). An unchanged re-apply keeps the stored bytes, so the run-time failure remains until the field is edited or the workflow is re-applied from another workspace.
    • Old file rows in workspace_resource_key no longer resolve. Nothing reads them.
    • The manifest lists at most 1000 files, oldest first, like the other kinds.
    • core.d.ts, syntax.mdx and SYNTAX.md are shared with other QA batches: B1 lands first, then this PR, then B5.

Type of Change

  • Bug fix

Testing

Each new test went red when its guard was reverted on its own (resolver, canonicalize lift, materialize uploadOf, files adapter pending path, manifest, SDK typing) and passes with the fix.

  • files.integration.ts (real Postgres + local storage):
    • A Files-tab upload named file('moved/a.txt') stores its id and storage key, and get prints file('moved/a.txt').
    • An unknown path is E_MAT_UNKNOWN_RESOURCE, with the workspace's paths as the hint.
    • The printed source applied to a second workspace binds that workspace's own file.
    • The "same apply uploads" check now uses file('contract.pdf').
  • files.integration.ts review follow-ups:
    • A path containing %20 under a top-level files folder resolves as written.
    • A malformed path (moved//a.txt) is E_MAT_UNKNOWN_RESOURCE, not a server error.
    • A member whose group withholds Files gets no file paths in the unknown-path hint.
  • read-source-resources.integration.ts: lists files by path, and omits them when the Files tab is hidden for the caller's group.
  • workspace-declarations.test.ts: a generated block's file-upload field accepts [file('moved/a.txt')], and an unlisted path is a type error.
  • Integration: 25 related suites passed (workspace-source, apply-workflow-source*, resource keys, manifest).
  • Package suites (workflow-code, workflow-sdk, sim-cli, workspace-code) and bun run test passed.
  • bun run generate, lint, type-check, the block registry check and check:api-validation:strict passed.
  • check:audits passed except knip, which reports the docs app's build-generated .content import as unresolved in a fresh worktree. This PR does not touch that file.

Checklist

  • Code follows project style guidelines
  • Self-reviewed my changes
  • Tests added/updated and passing (new tests pass the test-audit authoring gate)
  • 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 Dec 1, 2026 •

Copy link
Copy Markdown

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

Project Deployment Actions Updated
docs Ready Ready Preview Dec 1, 2026 8:24am UTC

Request Review

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 36 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

@greptile-apps

greptile-apps Bot commented Dec 1, 2026 •

Copy link
Copy Markdown
Contributor

Confidence Score: 5/5 · The PR appears safe to merge; no new blocking issue was found.RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no new blocking issue was found.

Summary

Workspace files now use their folder path and filename in file() references.

  • Workflow file fields resolve and print workspace files by path.
  • Workspace file paths appear in source listings and SDK checks.

No new actionable findings were accepted. Review was based on source inspection; no tests were run.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart LR
  A["file('docs/report.pdf')"] --> B["Match workspace path"]
  B --> C["Read live file metadata"]
  C --> D["Save editor-compatible upload object"]
  D --> E["Print file('docs/report.pdf')"]
  F["File created in same apply"] --> G["Pending path during planning"]
  G --> H["Write file before workflow"]
  H --> B
Loading

Reviews (5) · Last reviewed commit: "chore(workflow-sdk): regenerate core tex..." · Reviewed by Greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 36 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 36 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment •

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

All reported issues were addressed across 36 files

Reply with feedback, questions, or to request a fix.

Turn on auto-fix | Re-trigger cubic

Comment thread apps/docs/openapi-v2-workflows.json Resolved
file('<folder>/<name>') now resolves the workspace file at that path and
writes the object the editor's file picker stores (storage key and file
id), a stored workspace file prints back as file('<path>'), and the source
resources manifest and workspace.d.ts list file paths.
…itten, and report truncation exactly

- a path the stored workflow does not already hold resolves only for a caller whose group allows Files; any other caller gets the unknown-file finding a missing path gets
- resolve file() paths by exact name and folder path instead of the VFS reference parser, so files named content or meta.json inside a folder resolve
- read file pages until the manifest cap is filled so files no path names cannot hide a truncated list
- document the quoted file('docs/report.pdf') form in the manifest description
@waleedlatif1
waleedlatif1 force-pushed the fix/wac-qa-b3-file-references branch from a061b18 to be37ecf Compare December 1, 2026 08:18
@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@greptile

@waleedlatif1

Copy link
Copy Markdown
Collaborator Author

@cubic-dev-ai review this PR

@cubic-dev-ai

cubic-dev-ai Bot commented Dec 1, 2026

Copy link
Copy Markdown
Contributor

@cubic-dev-ai review this PR

@waleedlatif1 I have started the AI code review. It will take a few minutes to complete.

@cubic-dev-ai cubic-dev-ai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

No issues found across 36 files

Confidence score: 5/5

  • Automated review surfaced no issues in the provided summaries.
  • No files require special attention.

Turn on auto-fix | Re-trigger cubic

@waleedlatif1
waleedlatif1 merged commit ce74554 into staging Dec 1, 2026
87 checks passed

This branch was successfully deployed

1 active deployment
Preview — be37ecfa Deployed Dec 1, 2026 by vercel[bot]
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