fix: treat empty-string JSON env vars as absent in Configuration#965
fix: treat empty-string JSON env vars as absent in Configuration#965vdusek wants to merge 1 commit into
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #965 +/- ##
==========================================
- Coverage 89.91% 89.88% -0.04%
==========================================
Files 49 49
Lines 3085 3085
==========================================
- Hits 2774 2773 -1
- Misses 311 312 +1
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
|
||
| def test_actor_storages_env_var_empty_string_becomes_none(monkeypatch: pytest.MonkeyPatch) -> None: | ||
| """Test that an empty env var for actor_storages is converted to None instead of crashing.""" | ||
| monkeypatch.setenv('ACTOR_STORAGES_JSON', '') |
There was a problem hiding this comment.
Isn't this actually less defensive?
Is there any actual use case for having 'ACTOR_STORAGES_JSON' be set as an empty string? The env variable clearly states it should be a json. So either have json there, or don't set the variable.
Code should not try to guess the intention from an ambiguous action. And here we are guessing that an empty env variable probably means the user did not want to set it up in the first place...
Description
ACTOR_STORAGES_JSONandAPIFY_CHARGED_ACTOR_EVENT_COUNTSto an empty string instead of leaving them unset. Both validators passed the value straight tojson.loads(''), which raisesJSONDecodeErrorand crashesActor.init().''as absent in_load_storage_keysand in thecharged_event_countsvalidator, mirroring the existing_parse_actor_pricing_infobehavior.