Fix AttributeError when base_url is not set#152
Merged
jeff-schnitter merged 5 commits intostagingfrom Nov 4, 2025
Merged
Conversation
New version - 1.1.0
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 <noreply@anthropic.com>
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)
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.
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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