Skip to content

fix(files): authorize the workspace before resolving a files/ path - #9527

Merged
waleedlatif1 merged 2 commits into
stagingfrom
fix/files-vfs-path-authorize-first
Oct 31, 2026
Merged

waleedlatif1 merged 2 commits into
stagingfrom
fix/files-vfs-path-authorize-first

Conversation

@waleedlatif1

Copy link
Copy Markdown
Collaborator

Summary

  • fix(files): accept files/ VFS paths in v2 file describe, rename and delete #9504 resolved a files/… VFS path inside the caller-asserted workspace before any authorization. The not-found case was concealed, but the "names more than one file whose names display alike" error was thrown pre-authorization, so a non-member who knew a workspace id could learn that look-alike names exist at a path
  • defineAuthorizedWorkspaceFileUseCase now runs authorizeWorkspaceFileVfsPath first for path inputs: path syntax is still checked without touching the DB (a malformed path stays a validation error for everyone), then the asserted workspace is loaded and authorized with the operation's own minimum role — the same check the id path runs — and only then is the name looked up
  • Authorized members see identical results; id inputs are unchanged. A member below the operation's role now gets forbidden before the lookup (normal authorize-first order; v2 conceals it the same way)

Type of Change

  • Bug fix

Testing

  • file-path-references.integration.ts: a non-member gets the same outcome for an ambiguous, a missing and an existing path, and a dot-segment path is still a validation error. Ran locally against real Postgres: 10/10 with the fix; the new case fails on the pre-fix code
  • rename-workspace-file.test.ts, read-workspace-file-metadata.test.ts; biome; full gate in CI

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 Oct 31, 2026 •

Copy link
Copy Markdown

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

1 Skipped Deployment
Project Deployment Actions Updated
docs Skipped Skipped Oct 31, 2026 6:20pm UTC

Request Review

@greptile-apps

greptile-apps Bot commented Oct 31, 2026 •

Copy link
Copy Markdown
Contributor

RetriggerView in GreptileConfidence Score: 5/5

[Medium impact] The PR appears safe to merge; no actionable defects were found.

Summary

The PR hides file-path lookup errors from callers who cannot access the workspace.

  • File paths check workspace access before revealing lookup results.

Diagram

%%{init: {'theme': 'neutral'}}%%
flowchart TD
  A[File reference] --> B{Path or ID?}
  B -->|ID| C[Load canonical file]
  B -->|Path| D[Check syntax and look up path]
  D -->|Malformed| E[Return validation error]
  D -->|Resolved| C
  D -->|Missing or ambiguous| F[Load active workspace]
  F --> G[Check operation role and delegation scope]
  G -->|Denied| H[Return access refusal]
  G -->|Allowed| I[Return original lookup error]
  C --> J[Run existing file authorization]
  J --> K[Execute operation]
Loading

Reviews (2) · Last reviewed commit: "fix(files): admit a caller only when a f..." · Reviewed by Greptile

@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 3 files

This PR changes authentication, authorization, or input validation. Ultrareviews find 2.4x more serious bugs than standard reviews. Comment @cubic-dev-ai ultrareview to run one.

Turn on auto-fix | Re-trigger cubic

…and refuse file-scoped delegates there

Path resolution now throws a typed UnresolvedWorkspaceFileVfsPathError for a missing or
ambiguous path; defineAuthorizedWorkspaceFileUseCase authorizes the asserted workspace with
the operation's own options before letting it out. A resolved path keeps the single
authorization the id path runs, and a delegation scoped to one file gets the same refusal
for every other path.
@waleedlatif1
waleedlatif1 force-pushed the fix/files-vfs-path-authorize-first branch from 2c4e3f8 to ad3ce46 Compare October 31, 2026 18:20
@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 Oct 31, 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 4 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

This branch was previously deployed

1 inactive deployment
Preview — ad3ce46d Deployed Oct 31, 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