Skip to content

Conversation

@jeff-schnitter
Copy link
Collaborator

Problem

The CLI was crashing with AttributeError: 'NoneType' object has no attribute 'strip' in GitHub Actions workflows and other automated environments when:

  • No config file exists
  • CORTEX_BASE_URL environment variable is not set
  • --url flag is not provided

This 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 the url variable:

url = url.strip('"\' /')

However, when there's no config file (lines 97-112 path), the default URL was never set, leaving url as None.

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 url has a default value:

# Set default URL if not provided
if not url:
    url = "https://api.getcortexapp.com"

Changes

  • ✅ Added default URL check in cli.py before strip operation
  • ✅ Added test case test_no_base_url_defaults_correctly to verify the fix
  • ✅ All existing config tests pass

Testing

just test tests/test_config_file.py
# All 7 tests passed

The new test specifically reproduces the bug scenario and confirms the fix works.

Impact

  • Severity: High (broke GitHub Actions workflows)
  • Affected: v1.1.0
  • Fixed: This PR

Fixes #151

🤖 Generated with Claude Code

jeff-schnitter and others added 3 commits November 4, 2025 08:11
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.
@jeff-schnitter jeff-schnitter merged commit 360b11b into staging Nov 4, 2025
2 checks passed
@jeff-schnitter jeff-schnitter deleted the 151-fix-base-url-none-error branch November 5, 2025 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants