Skip to content

feat(config): implement spec-compliant devcontainerId derivation#252

Merged
skevetter merged 1 commit into
mainfrom
49ee/devcontainerid-spec-hash
May 6, 2026
Merged

feat(config): implement spec-compliant devcontainerId derivation#252
skevetter merged 1 commit into
mainfrom
49ee/devcontainerid-spec-hash

Conversation

@skevetter

Copy link
Copy Markdown
Contributor

Summary

Replaces the old devcontainerId derivation (SHA-256 hex prefix of workspace folder path, 20 chars) with the algorithm from the official devcontainer CLI source (devcontainers/cli at src/spec-common/variableSubstitution.ts):

  1. Serialize ID labels as JSON with sorted keys (matching JSON.stringify(labels, Object.keys(labels).sort()))
  2. SHA-256 hash the UTF-8 bytes of the JSON string
  3. Interpret the 32-byte hash as a BigInt and convert to base-32 (digits 0-9, letters a-v — same as JavaScript's BigInt.toString(32))
  4. Left-pad with '0' to exactly 52 characters

The new ComputeDevContainerID(labels map[string]string) function accepts arbitrary labels, supporting the --id-label CLI flag which overrides defaults. DeriveDevContainerID now takes both workspace folder and config file path to construct the spec-required default labels (devcontainer.local_folder and devcontainer.config_file).

LegacyDeriveDevContainerID is retained for backward compatibility. Container discovery is unaffected — it uses workspace UID via GetIDLabels, which is independent of the ${devcontainerId} variable substitution.

Replace the old SHA-256 hex-prefix derivation with the algorithm from
the official devcontainer CLI: SHA-256 of JSON-serialized sorted labels
→ BigInt → base-32 (0-9a-v alphabet) → left-pad to 52 characters.

The new ComputeDevContainerID accepts a labels map, enabling --id-label
override support. DeriveDevContainerID now takes both workspace folder
and config file path to construct the default labels per spec.

LegacyDeriveDevContainerID is retained for backward compatibility.
@netlify

netlify Bot commented May 6, 2026

Copy link
Copy Markdown

Deploy Preview for devsydev canceled.

Name Link
🔨 Latest commit 105320a
🔍 Latest deploy log https://app.netlify.com/projects/devsydev/deploys/69fbab033df31200081860fc

@github-actions github-actions Bot added the size/l label May 6, 2026
@coderabbitai

coderabbitai Bot commented May 6, 2026

Copy link
Copy Markdown

Warning

Rate limit exceeded

@skevetter has exceeded the limit for the number of commits that can be reviewed per hour. Please wait 16 minutes and 23 seconds before requesting another review.

To continue reviewing without waiting, purchase usage credits in the billing tab.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

ℹ️ Review info
⚙️ Run configuration

Configuration used: Organization UI

Review profile: CHILL

Plan: Pro

Run ID: f3074f1a-f280-4b54-b375-3067e72491d5

📥 Commits

Reviewing files that changed from the base of the PR and between 9563e32 and 105320a.

📒 Files selected for processing (3)
  • pkg/devcontainer/config.go
  • pkg/devcontainer/config/substitute.go
  • pkg/devcontainer/config/substitute_test.go

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

@skevetter
skevetter marked this pull request as ready for review May 6, 2026 21:10
@skevetter
skevetter enabled auto-merge (squash) May 6, 2026 21:10
@skevetter
skevetter merged commit d2ee4ab into main May 6, 2026
54 checks passed
@skevetter
skevetter deleted the 49ee/devcontainerid-spec-hash branch May 6, 2026 21:36
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant