From a9d372172022077062658e5e9d09c525b8ede325 Mon Sep 17 00:00:00 2001 From: GitHub Actions Date: Tue, 4 Nov 2025 16:12:13 +0000 Subject: [PATCH 1/4] chore: update HISTORY.md for main --- HISTORY.md | 8 ++++++++ 1 file changed, 8 insertions(+) diff --git a/HISTORY.md b/HISTORY.md index 8259555..abf5dd1 100644 --- a/HISTORY.md +++ b/HISTORY.md @@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/) and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html). +## [1.1.0](https://github.com/cortexapps/cli/releases/tag/1.1.0) - 2025-11-04 + +[Compare with 1.0.6](https://github.com/cortexapps/cli/compare/1.0.6...1.1.0) + +### Added + +- add: support for triggering scorecard entity evaluation ([66d73d9](https://github.com/cortexapps/cli/commit/66d73d9ec5ab6d2373736f636e53643abe06c063) by Jeff Schnitter). + ## [1.0.6](https://github.com/cortexapps/cli/releases/tag/1.0.6) - 2025-10-31 [Compare with 1.0.5](https://github.com/cortexapps/cli/compare/1.0.5...1.0.6) From cadf62e79c96fb6e89046d399d9247680e8057da Mon Sep 17 00:00:00 2001 From: Jeff Schnitter Date: Tue, 4 Nov 2025 08:28:45 -0800 Subject: [PATCH 2/4] fix: ensure base_url defaults correctly when not set MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit When base_url is not provided via config file or CORTEX_BASE_URL environment variable, the CLI now properly defaults to https://api.getcortexapp.com before attempting to strip the value. Previously, when no config file existed, url would remain None and cause an AttributeError when url.strip() was called. This affected GitHub Actions workflows and other automated environments. Changes: - Add safety check to set default URL if None before strip operation - Add test case to verify proper defaulting behavior Fixes #151 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude --- cortexapps_cli/cli.py | 8 ++++++++ tests/test_config_file.py | 25 +++++++++++++++++++++++++ 2 files changed, 33 insertions(+) diff --git a/cortexapps_cli/cli.py b/cortexapps_cli/cli.py index 8998fa5..9e5f417 100755 --- a/cortexapps_cli/cli.py +++ b/cortexapps_cli/cli.py @@ -23,6 +23,8 @@ import cortexapps_cli.commands.deploys as deploys import cortexapps_cli.commands.discovery_audit as discovery_audit import cortexapps_cli.commands.docs as docs +import cortexapps_cli.commands.entity_relationships as entity_relationships +import cortexapps_cli.commands.entity_relationship_types as entity_relationship_types import cortexapps_cli.commands.entity_types as entity_types import cortexapps_cli.commands.gitops_logs as gitops_logs import cortexapps_cli.commands.groups as groups @@ -57,6 +59,8 @@ app.add_typer(deploys.app, name="deploys") app.add_typer(discovery_audit.app, name="discovery-audit") app.add_typer(docs.app, name="docs") +app.add_typer(entity_relationships.app, name="entity-relationships") +app.add_typer(entity_relationship_types.app, name="entity-relationship-types") app.add_typer(entity_types.app, name="entity-types") app.add_typer(gitops_logs.app, name="gitops-logs") app.add_typer(groups.app, name="groups") @@ -121,6 +125,10 @@ def global_callback( else: url = "https://api.getcortexapp.com" + # Set default URL if not provided + if not url: + url = "https://api.getcortexapp.com" + # strip any quotes or spaces from the api_key and url api_key = api_key.strip('"\' ') url = url.strip('"\' /') diff --git a/tests/test_config_file.py b/tests/test_config_file.py index 1c356dc..f37cc81 100644 --- a/tests/test_config_file.py +++ b/tests/test_config_file.py @@ -70,3 +70,28 @@ def test_config_file_base_url_env_var(monkeypatch, tmp_path): f.write_text(content) monkeypatch.setenv("CORTEX_BASE_URL", "https://api.getcortexapp.com") cli(["-c", str(f), "-t", "mySection", "entity-types", "list"]) + +def test_no_base_url_defaults_correctly(monkeypatch, tmp_path): + """ + Test that when base_url is not provided via config file or environment variable, + the CLI defaults to https://api.getcortexapp.com without crashing. + + This reproduces the bug from issue #151 where url.strip() was called on None. + """ + # Remove CORTEX_BASE_URL from environment + monkeypatch.delenv("CORTEX_BASE_URL", raising=False) + + cortex_api_key = os.getenv('CORTEX_API_KEY') + + # Create config file WITHOUT base_url + f = tmp_path / "cortex_config_no_base_url" + template = Template(""" + [default] + api_key = "${cortex_api_key}" + """) + content = template.substitute(cortex_api_key=cortex_api_key) + f.write_text(content) + + # This should not crash and should use the default URL + response = cli(["-c", str(f), "entity-types", "list"]) + assert 'definitions' in response, "Should successfully call API with default URL" From 3d467f699a0d4883316e039fcca571bde03d7f0a Mon Sep 17 00:00:00 2001 From: Jeff Schnitter Date: Tue, 4 Nov 2025 10:14:32 -0800 Subject: [PATCH 3/4] fix: remove entity_relationships imports from wrong branch Remove imports and app.add_typer calls for entity_relationships modules that were accidentally included from another branch. These modules don't exist yet and were causing ModuleNotFoundError in CI. Related to #148 (not part of this fix) --- cortexapps_cli/cli.py | 4 ---- 1 file changed, 4 deletions(-) diff --git a/cortexapps_cli/cli.py b/cortexapps_cli/cli.py index 9e5f417..03d471d 100755 --- a/cortexapps_cli/cli.py +++ b/cortexapps_cli/cli.py @@ -23,8 +23,6 @@ import cortexapps_cli.commands.deploys as deploys import cortexapps_cli.commands.discovery_audit as discovery_audit import cortexapps_cli.commands.docs as docs -import cortexapps_cli.commands.entity_relationships as entity_relationships -import cortexapps_cli.commands.entity_relationship_types as entity_relationship_types import cortexapps_cli.commands.entity_types as entity_types import cortexapps_cli.commands.gitops_logs as gitops_logs import cortexapps_cli.commands.groups as groups @@ -59,8 +57,6 @@ app.add_typer(deploys.app, name="deploys") app.add_typer(discovery_audit.app, name="discovery-audit") app.add_typer(docs.app, name="docs") -app.add_typer(entity_relationships.app, name="entity-relationships") -app.add_typer(entity_relationship_types.app, name="entity-relationship-types") app.add_typer(entity_types.app, name="entity-types") app.add_typer(gitops_logs.app, name="gitops-logs") app.add_typer(groups.app, name="groups") From 6715ea8ace42e5e137b649daf927bf2bec225b5e Mon Sep 17 00:00:00 2001 From: Jeff Schnitter Date: Tue, 4 Nov 2025 11:16:12 -0800 Subject: [PATCH 4/4] fix: handle 409 Already evaluating in trigger-evaluation test The trigger-evaluation command can return either: - Success message when evaluation is triggered - 409 Conflict when scorecard is already being evaluated Both are valid outcomes and the test should accept either. Updates test assertion to accept both success and 409 responses. --- tests/test_scorecards.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/tests/test_scorecards.py b/tests/test_scorecards.py index 0368c42..9ec4216 100644 --- a/tests/test_scorecards.py +++ b/tests/test_scorecards.py @@ -27,9 +27,10 @@ def test_scorecards(): # cannot rely on a scorecard evaluation being complete, so not performing any validation cli(["scorecards", "next-steps", "-s", "cli-test-scorecard", "-t", "cli-test-service"]) - # Test trigger-evaluation command + # Test trigger-evaluation command (accepts both success and 409 Already evaluating) response = cli(["scorecards", "trigger-evaluation", "-s", "cli-test-scorecard", "-e", "cli-test-service"], return_type=ReturnType.STDOUT) - assert "Scorecard evaluation triggered successfully" in response, "Should receive success message when triggering evaluation" + assert ("Scorecard evaluation triggered successfully" in response or "Already evaluating scorecard" in response), \ + "Should receive success message or 409 Already evaluating error" # cannot rely on a scorecard evaluation being complete, so not performing any validation #response = cli(["scorecards", "scores", "-s", "cli-test-scorecard", "-t", "cli-test-service"])