Skip to content

Commit 360b11b

Browse files
Merge pull request #152 from cortexapps/151-fix-base-url-none-error
Fix AttributeError when base_url is not set Force merge because I want to get this fix deployed ASAP.
2 parents 6a69b52 + 6715ea8 commit 360b11b

File tree

4 files changed

+40
-2
lines changed

4 files changed

+40
-2
lines changed

HISTORY.md

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,14 @@ The format is based on [Keep a Changelog](http://keepachangelog.com/en/1.0.0/)
66
and this project adheres to [Semantic Versioning](http://semver.org/spec/v2.0.0.html).
77

88
<!-- insertion marker -->
9+
## [1.1.0](https://github.com/cortexapps/cli/releases/tag/1.1.0) - 2025-11-04
10+
11+
<small>[Compare with 1.0.6](https://github.com/cortexapps/cli/compare/1.0.6...1.1.0)</small>
12+
13+
### Added
14+
15+
- add: support for triggering scorecard entity evaluation ([66d73d9](https://github.com/cortexapps/cli/commit/66d73d9ec5ab6d2373736f636e53643abe06c063) by Jeff Schnitter).
16+
917
## [1.0.6](https://github.com/cortexapps/cli/releases/tag/1.0.6) - 2025-10-31
1018

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

cortexapps_cli/cli.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -121,6 +121,10 @@ def global_callback(
121121
else:
122122
url = "https://api.getcortexapp.com"
123123

124+
# Set default URL if not provided
125+
if not url:
126+
url = "https://api.getcortexapp.com"
127+
124128
# strip any quotes or spaces from the api_key and url
125129
api_key = api_key.strip('"\' ')
126130
url = url.strip('"\' /')

tests/test_config_file.py

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -70,3 +70,28 @@ def test_config_file_base_url_env_var(monkeypatch, tmp_path):
7070
f.write_text(content)
7171
monkeypatch.setenv("CORTEX_BASE_URL", "https://api.getcortexapp.com")
7272
cli(["-c", str(f), "-t", "mySection", "entity-types", "list"])
73+
74+
def test_no_base_url_defaults_correctly(monkeypatch, tmp_path):
75+
"""
76+
Test that when base_url is not provided via config file or environment variable,
77+
the CLI defaults to https://api.getcortexapp.com without crashing.
78+
79+
This reproduces the bug from issue #151 where url.strip() was called on None.
80+
"""
81+
# Remove CORTEX_BASE_URL from environment
82+
monkeypatch.delenv("CORTEX_BASE_URL", raising=False)
83+
84+
cortex_api_key = os.getenv('CORTEX_API_KEY')
85+
86+
# Create config file WITHOUT base_url
87+
f = tmp_path / "cortex_config_no_base_url"
88+
template = Template("""
89+
[default]
90+
api_key = "${cortex_api_key}"
91+
""")
92+
content = template.substitute(cortex_api_key=cortex_api_key)
93+
f.write_text(content)
94+
95+
# This should not crash and should use the default URL
96+
response = cli(["-c", str(f), "entity-types", "list"])
97+
assert 'definitions' in response, "Should successfully call API with default URL"

tests/test_scorecards.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -27,9 +27,10 @@ def test_scorecards():
2727
# cannot rely on a scorecard evaluation being complete, so not performing any validation
2828
cli(["scorecards", "next-steps", "-s", "cli-test-scorecard", "-t", "cli-test-service"])
2929

30-
# Test trigger-evaluation command
30+
# Test trigger-evaluation command (accepts both success and 409 Already evaluating)
3131
response = cli(["scorecards", "trigger-evaluation", "-s", "cli-test-scorecard", "-e", "cli-test-service"], return_type=ReturnType.STDOUT)
32-
assert "Scorecard evaluation triggered successfully" in response, "Should receive success message when triggering evaluation"
32+
assert ("Scorecard evaluation triggered successfully" in response or "Already evaluating scorecard" in response), \
33+
"Should receive success message or 409 Already evaluating error"
3334

3435
# cannot rely on a scorecard evaluation being complete, so not performing any validation
3536
#response = cli(["scorecards", "scores", "-s", "cli-test-scorecard", "-t", "cli-test-service"])

0 commit comments

Comments
 (0)