Skip to content

Fail fast on missing DISTRO and map focal/jammy to ubuntu20/ubuntu22#117

Merged
ofiryanai merged 3 commits into
masterfrom
fix-ubuntu-nicks
Jun 4, 2026
Merged

Fail fast on missing DISTRO and map focal/jammy to ubuntu20/ubuntu22#117
ofiryanai merged 3 commits into
masterfrom
fix-ubuntu-nicks

Conversation

@ofiryanai

@ofiryanai ofiryanai commented Jun 4, 2026

Copy link
Copy Markdown
Contributor

Fail fast when DISTRO is missing from the devcontainer file, and map focal/jammy to ubuntu20/ubuntu22.

@ofiryanai ofiryanai marked this pull request as ready for review June 4, 2026 13:45
@ofiryanai ofiryanai requested a review from alonre24 June 4, 2026 13:45
Comment thread RAMP/module_metadata.py Outdated
devcontainer_os = _read_key_value_file(DEVCONTAINER_PATH)["DISTRO"]
return (devcontainer_os
.replace("focal", "ubuntu20")
.replace("jammy", "ubuntu22"))

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Do we need a similar hack for noble -> ubuntu24?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

there's still no noble distribution in RE. I'll add it now

@eyalrund

eyalrund commented Jun 4, 2026

Copy link
Copy Markdown
  • The "fail fast" is a bare KeyError with no friendly message — intentional per the title, but a wrapped error like raise ValueError("DISTRO missing from devcontainer at ") would be more debuggable for whoever hits it in CI.
  • .replace() does substring replacement, so a hypothetical DISTRO=focal-test would become ubuntu20-test. Harmless given the controlled input set, but a dict lookup ({"focal":"ubuntu20","jammy":"ubuntu22"}.get(v, v)) would be more precise and easier to extend.

@eyalrund eyalrund 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.

  • The "fail fast" is a bare KeyError with no friendly message — intentional per the title, but a wrapped error like raise ValueError("DISTRO missing from devcontainer at ") would be more debuggable for whoever hits it in CI.
  • .replace() does substring replacement, so a hypothetical DISTRO=focal-test would become ubuntu20-test. Harmless given the controlled input set, but a dict lookup ({"focal":"ubuntu20","jammy":"ubuntu22"}.get(v, v)) would be more precise and easier to extend.

Comment thread RAMP/module_metadata.py Outdated
Comment on lines +119 to +121
return (devcontainer_os
.replace("focal", "ubuntu20")
.replace("jammy", "ubuntu22"))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Don't we have a map for such translations, instead of these two specific switches? Shouldn't we have such a map?
Then we can have something like

  return os_name_normalized.get(devcontainer_os, devcontainer_os)

to fetch the expected name, and fall back to the current name if nothing special is set

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

we can, I didn't bother since it didn't seem more readable. let me change to that.

@ofiryanai ofiryanai requested review from GuyAv46, eyalrund and nafraf June 4, 2026 14:37
@ofiryanai ofiryanai merged commit 9937a40 into master Jun 4, 2026
5 checks passed
@ofiryanai ofiryanai deleted the fix-ubuntu-nicks branch June 4, 2026 14:53
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.

5 participants