Skip to content

unpack built-in blueprints - #265

Draft
maxwellpeterson wants to merge 2 commits into
mainfrom
mpeterson/blueprint-unpack
Draft

unpack built-in blueprints#265
maxwellpeterson wants to merge 2 commits into
mainfrom
mpeterson/blueprint-unpack

Conversation

@maxwellpeterson

Copy link
Copy Markdown
Member
  • store blueprint source files in source control instead of .gadget archive
  • this makes it much easier to develop and review changes to built-in blueprints

- store gadget source files in source control instead of .gadget
  archives
- this makes it much easier to develop and review changes to built-in
  blueprints
@github-actions github-actions Bot added the kernel Changes to the Workshop kernel label Aug 19, 2026
@github-actions

Copy link
Copy Markdown

Preview: pr265-mpeterson-blu-c19bb921

https://pr265-mpeterson-blu-c19bb921-router.cloudflare-os-previews.workers.dev

Dashboard · deleted when this PR closes

github-advanced-security[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

github-advanced-security[bot]

This comment was marked as resolved.

@devin-ai-integration devin-ai-integration 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.

Devin Review found 1 new potential issue.

View 1 additional finding in Devin Review.

Open in Devin Review

Comment on lines +45 to +46
for (const entry of (await readdir(sourceDir, {withFileTypes: true}))
.filter(entry => entry.isDirectory()).toSorted((a, b) => a.name < b.name ? -1 : 1)) {

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

🟡 Re-importing a bundled format after an interrupted import silently updates a leftover hidden folder instead of the real blueprint

Leftover hidden staging/backup folders from an interrupted import are treated as real blueprints (readdir(...).filter(entry => entry.isDirectory()) at packages/workshop-backend/scripts/import-format-blueprint.ts:45-46) when looking up which blueprint to update, so a later import can write the new code into the leftover folder and leave the shipped blueprint unchanged.
Impact: The import command reports success while the bundled format keeps its old code, so the update never reaches deployments.

How a hidden leftover directory hijacks the blueprintId lookup

The installer stages into .<name>.import-<pid>/ and moves the previous directory to .<name>.backup-<pid>/ (packages/workshop-backend/scripts/import-format-blueprint.ts:144-157). If the process is interrupted (Ctrl-C, I/O error where the restore rename fails with ENOTEMPTY), one of those hidden directories survives, containing a blueprint.json with the same blueprintId.

On the next run, the manifest scan does not skip dot-prefixed entries, so both the leftover and the real directory are collected. Because . sorts before letters, manifests.find(candidate => candidate.blueprintId === blueprintId) (line 86) resolves to the leftover, making entry.name the hidden directory: the new files are written there, workspace-docs/ is untouched, and the generator (packages/workshop-backend/scripts/build-format-blueprints.ts:126-127, which deliberately filters dot entries — see scripts/build-format-blueprints.test.ts) keeps bundling the stale source. The only hint is the directory name printed in the summary.

Filtering entry.name.startsWith(".") here, matching the generator, avoids it.

Suggested change
for (const entry of (await readdir(sourceDir, {withFileTypes: true}))
.filter(entry => entry.isDirectory()).toSorted((a, b) => a.name < b.name ? -1 : 1)) {
for (const entry of (await readdir(sourceDir, {withFileTypes: true}))
.filter(entry => entry.isDirectory() && !entry.name.startsWith("."))
.toSorted((a, b) => a.name < b.name ? -1 : 1)) {
Open in Devin Review

Was this helpful? React with 👍 or 👎 to provide feedback.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kernel Changes to the Workshop kernel

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants