Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions HISTORY.md
Original file line number Diff line number Diff line change
Expand Up @@ -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).

<!-- insertion marker -->
## [1.1.0](https://github.com/cortexapps/cli/releases/tag/1.1.0) - 2025-11-04

<small>[Compare with 1.0.6](https://github.com/cortexapps/cli/compare/1.0.6...1.1.0)</small>

### 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

<small>[Compare with 1.0.5](https://github.com/cortexapps/cli/compare/1.0.5...1.0.6)</small>
Expand Down
4 changes: 4 additions & 0 deletions cortexapps_cli/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -121,6 +121,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('"\' /')
Expand Down
25 changes: 25 additions & 0 deletions tests/test_config_file.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"
5 changes: 3 additions & 2 deletions tests/test_scorecards.py
Original file line number Diff line number Diff line change
Expand Up @@ -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"])
Expand Down