Skip to content

fix(build): reject dist paths Hub cannot store - #360

Open
kenilghetia wants to merge 1 commit into
github:mainfrom
kenilghetia:fix/build-reject-hub-unstorable-paths
Open

kenilghetia wants to merge 1 commit into
github:mainfrom
kenilghetia:fix/build-reject-hub-unstorable-paths

Conversation

@kenilghetia

Copy link
Copy Markdown

Why

The build action accepts some dist file paths that Hub later refuses to store. The prototype's workflow succeeds and uploads its package, and then the Build fails during Hub's import. The message does not say which file caused it: "package contains an unsupported path or entry type". The author has to wait for a full CI run and then work out the cause alone.

I found this while setting up the monorepo locally. I ran the build action tests and Hub's Build model tests in separate containers, then passed packages built by the real action scripts to Hub's real Build::PackageExtraction. An ordinary build passed both. A build containing a .replica-internal folder, or a file path longer than Hub's storage allows, passed the action and failed in Hub.

This is a developer-experience and reliability fix, not a security fix. Hub's checks already keep these paths out of storage. Few builds will hit it, but those that do currently fail late and without a useful message.

Closes #359

What changes

The action's dist path check, validateOutputPath, gains the two Hub storage rules it was missing. Most rules already match: the action's 20-segment depth limit mirrors Hub, and its template validator already rejects .replica-internal.

  • Reserved name. A path segment named .replica-internal is rejected. Hub reserves that name for its storage layout. The comparison is case-sensitive, like Hub's.
  • Path length. A dist path longer than 992 bytes is rejected. Hub stores each file as builds/{Build ID}/dist/{path} and limits that whole name to 1,024 bytes. Reserving 32 bytes for the prefix with the largest 64-bit Build ID gives a limit that fits every Build.

Both errors name the path and the rule, like the action's other path errors:

Build output path must not use .replica-internal, which Hub reserves for its storage: assets/.replica-internal
Build output path must be at most 992 bytes for Hub storage: <path> has 993 bytes.

Because the check sits in the shared output validation, it applies at every point where the action validates output. That includes Hub's local-development packaging, which reuses these scripts. The output limits table and description in hub/docs/github-actions-builds.md now list both rules.

flowchart LR
  subgraph Before
    A1[Prototype build] --> B1[Action checks pass] --> C1[Workflow succeeds<br/>package uploaded] --> D1[Hub import fails<br/>file not named]
  end
  subgraph After
    A2[Prototype build] --> B2[Action rejects the path<br/>and names it] --> C2[Author fixes the build<br/>in the same run]
  end
Loading

Two regression tests cover the change. One checks that a .replica-internal directory is rejected. The other checks the exact length boundary: a 992-byte path is accepted and a 993-byte path is rejected.

The limit is deliberately conservative. For small Build IDs, Hub would accept some paths between 993 and about 1,007 bytes that the action now rejects. The action cannot know the Build ID in advance, and paths that long are very unlikely from real bundlers, so I chose a fixed limit that fits every Build. I'm happy to change it if you prefer another trade-off.

The change was verified against the action's scripts and Hub's extractor in containers, not in a live GitHub Actions run with actions/upload-artifact. The new checks run before upload, so that step is unaffected.

The build action accepted two kinds of dist path that Hub refuses when it
imports the package: a .replica-internal segment, which Hub reserves for
its storage, and paths that exceed Hub's 1,024-byte storage-name limit
once stored as builds/{Build ID}/dist/{path}. The workflow succeeded and
the Build then failed in Hub without naming the file.

Reject both in validateOutputPath with errors that name the path. The
992-byte limit reserves 32 bytes for the prefix with the largest 64-bit
Build ID, so it fits every Build. Document both rules with the other
output limits.
@kenilghetia
kenilghetia requested review from a team and nshki as code owners November 24, 2026 19:29
Copilot AI adaptive review requested due to automatic review settings November 24, 2026 19:29

Copilot AI 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.

🟢 Approval recommended

No active review issues block the change that rejects unsupported build-output paths before upload.

No open issues 🎉

What changed in this PR

This PR moves two Hub storage checks into the shared build-output validator, so unsupported dist paths fail before upload with an error naming the offending path.

Changes:

  • Reject paths containing a .replica-internal segment or exceeding the conservative 992-byte limit.
  • Add regression tests for the reserved name and the 992/993-byte boundary.
  • Document the storage restrictions and path-length limit.
File Description
hub/​docs/​github-actions-builds.md Documents reserved paths and the 992-byte limit.
actions/​build/​scripts/​validate-output-path/​index.ts Adds early validation with path-specific errors.
actions/​build/​scripts/​validate-build-output/​index.test.ts Covers reserved-name rejection and the length boundary.
actions/​build/​scripts/​constants.ts Defines the shared path-length limit.

Review effort: Balanced (adaptive)

@kenilghetia

Copy link
Copy Markdown
Author

Hi @nshki
Whenever you get a chance, would appreciate your thoughts on this PR. Thanks :)

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.

Build action accepts dist paths that Hub cannot store

2 participants