-
Notifications
You must be signed in to change notification settings - Fork 0
fix: preflight optional YAML output before reconciliation #34
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Merged
codeforester
merged 3 commits into
main
from
bug/21-20260918-bug-make-advertised-yaml-output-usable-before-reconciliation
Sep 19, 2026
Merged
Changes from all commits
Commits
Show all changes
3 commits
Select commit
Hold shift + click to select a range
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,14 @@ | ||
| # Optional YAML Output | ||
|
|
||
| YAML is a supported Base-CLI renderer, but it is intentionally not part of the | ||
| demo's minimal dependencies. Install the optional extra before using | ||
| `--format yaml`: | ||
|
|
||
| ```console | ||
| $ python -m pip install "base-cli-demo[yaml]" | ||
| $ northstar --quiet status --format yaml | ||
| ``` | ||
|
|
||
| Without the extra, Northstar reports this install command before running the | ||
| consumer command. In particular, a reconciliation does not persist local state | ||
| and then fail while trying to render YAML. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,42 @@ | ||
| from __future__ import annotations | ||
|
|
||
| import importlib.util | ||
| from pathlib import Path | ||
| from typing import Any | ||
|
|
||
| import base_cli | ||
| import pytest | ||
|
|
||
| from base_cli_demo.cli import command | ||
|
|
||
|
|
||
| def invoke(args: list[str], home: Path) -> Any: | ||
| return base_cli.testing.invoke(command, ["--quiet", *args], home=home) | ||
|
|
||
|
|
||
| def test_yaml_without_optional_renderer_fails_before_reconciliation_state( | ||
| monkeypatch: pytest.MonkeyPatch, tmp_path: Path | ||
| ) -> None: | ||
| def missing_renderer(_name: str) -> object: | ||
| raise ModuleNotFoundError("yaml") | ||
|
|
||
| monkeypatch.setattr("base_cli_demo.cli.import_module", missing_renderer) | ||
| result = invoke(["release", "reconcile", "--format", "yaml"], tmp_path) | ||
|
|
||
| assert result.exit_code == 1 | ||
| assert "base-cli-demo[yaml]" in result.output + getattr(result, "stderr", "") | ||
| assert list(tmp_path.rglob("last-reconciliation.json")) == [] | ||
|
|
||
|
|
||
| def test_yaml_output_renders_with_the_optional_extra(tmp_path: Path) -> None: | ||
| if importlib.util.find_spec("yaml") is None: | ||
| pytest.skip("PyYAML is installed by the optional yaml extra") | ||
|
|
||
| result = base_cli.testing.invoke( | ||
| command, | ||
| ["--quiet", "status", "--format", "yaml"], | ||
| home=tmp_path, | ||
| ) | ||
|
|
||
| assert result.exit_code == 0, result.output | ||
| assert "service: orders-api" in result.stdout |
Oops, something went wrong.
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Altitude: the consumer re-implements "is the optional YAML renderer available" via
find_specinstead of reusing base_cli's own check, letting the two diverge (see the find_spec-vs-import gap flagged on line 28). base_cli only exposes this as the privatebase_cli._dependencies.require_yaml(a real try/import, not find_spec) — there's no public preflight helper, so every consumer with a--formatoption has to hand-roll an equivalent, and a future optional format would need the same ad hoc logic copy-pasted again instead of one shared, correct base_cli entry point.Flagged by automated review (base-cli-demo#34).