Skip to content

Fix AttributeError when running lemur CLI without config#5401

Merged
jmcrawford45 merged 2 commits intoNetflix:mainfrom
0xb8000:fix/4764-cli-rotate-missing-command
Apr 8, 2026
Merged

Fix AttributeError when running lemur CLI without config#5401
jmcrawford45 merged 2 commits intoNetflix:mainfrom
0xb8000:fix/4764-cli-rotate-missing-command

Conversation

@0xb8000
Copy link
Copy Markdown

@0xb8000 0xb8000 commented Apr 6, 2026

Summary

  • Fix getattr(script_info, 'config') in factory.py to use a default value of None, preventing AttributeError when running lemur --help or lemur without a subcommand

When create_app is called during --help processing, the script_info object may not yet have the config attribute set (it's set by the cli callback in manage.py). Without a default, getattr raises AttributeError.

This addresses the first problem reported in #4764. The other problems mentioned (missing @with_appcontext on custom plugin CLI commands, and missing @cli.command() on rotate) appear to have been resolved in subsequent commits — rotate is correctly registered and visible in lemur certificate --help.

Closes #4764

Test plan

  • lemur --help runs successfully and shows all commands
  • lemur certificate --help shows rotate and all other subcommands
  • Confirmed the original code raises AttributeError when script_info lacks the config attribute

🤖 Generated with Claude Code

getattr(script_info, 'config') raises AttributeError when the
script_info object doesn't have a config attribute set yet (e.g.
when running 'lemur --help' or 'lemur' without a subcommand).

Use getattr with a default of None to handle this gracefully.

Closes Netflix#4764

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@jmcrawford45 jmcrawford45 enabled auto-merge April 7, 2026 15:51
@coveralls
Copy link
Copy Markdown

coveralls commented Apr 7, 2026

Coverage Status

Coverage is 60.861%0xb8000:fix/4764-cli-rotate-missing-command into Netflix:main. No base build found for Netflix:main.

@jmcrawford45 jmcrawford45 merged commit cd2b4fb into Netflix:main Apr 8, 2026
9 checks passed
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.

Error message with CLI command and "Working outside of application context"

4 participants