Skip to content

fix: use get_project_base() in Extension.validate() - #1310

Open
Thanhphan1147 wants to merge 2 commits into
canonical:mainfrom
Thanhphan1147:fix_get_supported_bases
Open

fix: use get_project_base() in Extension.validate()#1310
Thanhphan1147 wants to merge 2 commits into
canonical:mainfrom
Thanhphan1147:fix_get_supported_bases

Conversation

@Thanhphan1147

Copy link
Copy Markdown
Contributor

Extension.validate() is still using the raw base value from yaml_data:

base: str = self.yaml_data["base"]

However, with the new extension dispatch, _FrameworkFactory.__call__ uses get_project_base, which gives build-base precedence over base and more importantly use the value of build-base when base is bare. This breaks some workflow where the user sets build-base: ubuntu@26.04 and base: bare and rockcraft would report:

rockcraft.errors.ExtensionError: Extension 'expressjs-framework' does not support base: 'bare'

  • I've followed the contribution guidelines.
  • I've signed the CLA.
  • I've successfully run make lint && make test.
  • I've added or updated any relevant documentation.
  • In documents I changed, I added a meta description if one was missing.
  • I've updated the relevant release notes.

@Thanhphan1147
Thanhphan1147 requested a review from tigarmo as a code owner July 22, 2026 18:02
Copilot AI review requested due to automatic review settings July 22, 2026 18:02
@Thanhphan1147 Thanhphan1147 changed the title feat: use get_project_base() in Extension.validate() fix: use get_project_base() in Extension.validate() Jul 22, 2026

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.

Pull request overview

This PR aligns Extension.validate() with the extension factory dispatch logic by using get_project_base() (which gives build-base precedence over base and normalizes legacy ubuntu:<series> syntax). This prevents extensions from incorrectly rejecting projects that use base: bare alongside a real Ubuntu build-base.

Changes:

  • Update Extension.validate() to resolve the effective base via get_project_base() (falling back to the raw base field when it can’t be resolved).
  • Adjust unit test expectations to match get_project_base() normalization of legacy ubuntu:<series> format.
  • Add a regression test ensuring base: bare + build-base: ubuntu@26.04 dispatches to ExpressJS V2 without raising an extension base incompatibility error.

Reviewed changes

Copilot reviewed 3 out of 3 changed files in this pull request and generated no comments.

File Description
rockcraft/extensions/extension.py Use get_project_base() in Extension.validate() so validation matches dispatch rules (notably build-base precedence).
tests/unit/extensions/test_extensions.py Update parametrization and expected error message to reflect base normalization (:@).
tests/unit/extensions/test_expressjs.py Add regression test for base: bare + build-base: ubuntu@26.04 dispatch/validation behavior.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

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.

2 participants