Fix AttributeError when base_url is not set #152
Merged
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.
Problem
The CLI was crashing with
AttributeError: 'NoneType' object has no attribute 'strip'in GitHub Actions workflows and other automated environments when:CORTEX_BASE_URLenvironment variable is not set--urlflag is not providedThis bug was discovered when the publish workflow failed to post custom events to Cortex production after promoting v1.1.0 to main.
Root Cause
In
cortexapps_cli/cli.py:130, the code tries to strip theurlvariable:However, when there's no config file (lines 97-112 path), the default URL was never set, leaving
urlasNone.The default URL was only set in the else block (line 126) when a config file exists.
Solution
Added a safety check before the strip operation to ensure
urlhas a default value:Changes
cli.pybefore strip operationtest_no_base_url_defaults_correctlyto verify the fixTesting
The new test specifically reproduces the bug scenario and confirms the fix works.
Impact
Fixes #151
🤖 Generated with Claude Code