NoneType error in FeatureState.get_create_log_message when environment default is missing
Nobody has claimed this yet.
Assessment
- Difficulty
- 2/5
- Estimated time
- 1-3 hours
- Newbie friendliness
- 72/100
Research direction
Start in features/models.py at line 941 and read get_create_log_message together with get_environment_default. Confirm the missing environment default path, then ensure the method no longer dereferences None and verify the intended audit-log behavior for that case.
Written by the indexing model from the issue text.
Description
AttributeError: 'NoneType' object has no attribute 'enabled' in features/models.py:941 — the get_create_log_message method calls self.get_environment_default() which returns None, then tries to access .enabled on it.
Sentry Issue: FLAGSMITH-API-5JG — all from the same trace during a bulk operation on project "snapshot-hdf1".
Root Cause
At features/models.py:941:
and self.enabled == self.get_environment_default().enabled # type: ignore[union-attr]
get_environment_default() returns None when the environment default FeatureState no longer exists (likely deleted concurrently). The existing # type: ignore[union-attr] comment acknowledges this possibility but doesn't handle it.
Suggested Fix
Guard against None:
env_default = self.get_environment_default()
if env_default is not None and self.enabled == env_default.enabled:
Or skip audit log creation when the environment default is missing.
- Dominant language
- Python
- Stars
- 6.6k
- Forks
- 571
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 116
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
More from Flagsmith/flagsmith
-
Difficulty 2/5 1-3 hours Newbie friendliness 68/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Sales dashboard: download_org_data 500s with "Object of type generator is not JSON serializable" Open
Difficulty 2/5 1-3 hours Newbie friendliness 86/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 65/100
All issues in Flagsmith/flagsmith
Similar issues
-
Difficulty 2/5 1-3 hours Newbie friendliness 88/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 82/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 78/100
-
enhancement
Difficulty 2/5 1-3 hours Newbie friendliness 72/100
-
Difficulty 2/5 1-3 hours Newbie friendliness 74/100