Skip to content

bugfix: call ensure_conf() in generate_key() - #346

Open
StayPirate wants to merge 1 commit into
sibson:mainfrom
StayPirate:fix/generate-key-ensure-conf
Open

StayPirate wants to merge 1 commit into
sibson:mainfrom
StayPirate:fix/generate-key-ensure-conf

Conversation

@StayPirate

Copy link
Copy Markdown

Fixes #345

generate_key() was the only entry point reading app.redbeat_conf directly instead of going through ensure_conf(), so if nothing else in the process had touched RedBeat yet (e.g. a web process that only loads or deletes entries by name, like the snippet in docs/tasks.rst) the first call failed with AttributeError.

The fix is the one-liner from the issue. I added a test that calls generate_key() on a fresh app. The existing test_generate_key didn't catch it because it creates an entry first, and that already sets up the config.

The new test compares against redbeat_conf.key_prefix instead of hardcoding redbeat:, because on a fresh test app the prefix comes out as rb-tests: (the one basecase sets) while the old test gets redbeat:. Looks like a celery conf quirk in the test setup, I didn't dig further since it's unrelated.

make test and make lint pass locally.

generate_key() read app.redbeat_conf directly, so it raised
AttributeError when nothing else in the process had initialized the
config yet, e.g. a web process that only looks up an entry by name as
shown in docs/tasks.rst. The other entry points already go through
ensure_conf().

Fixes sibson#345

This branch has not been deployed

No deployments
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.

generate_key() raises AttributeError before redbeat_conf is initialized

1 participant