Skip to content

fix(settings): degrade load_features to defaults on PermissionError#3856

Merged
alteixeira20 merged 2 commits into
odysseus-dev:devfrom
mazen-salah:fix/load-features-permission-error
Jun 11, 2026
Merged

fix(settings): degrade load_features to defaults on PermissionError#3856
alteixeira20 merged 2 commits into
odysseus-dev:devfrom
mazen-salah:fix/load-features-permission-error

Conversation

@mazen-salah

Copy link
Copy Markdown
Contributor

Summary

load_features() caught only FileNotFoundError, json.JSONDecodeError, and ValueError, while its sibling load_settings() also catches PermissionError. So an existing-but-unreadable data/features.json (e.g. root-owned after a deploy) raised instead of falling back to DEFAULT_FEATURES, taking down GET /api/auth/features and anything that reads feature flags. This adds PermissionError to the except tuple to match load_settings().

Target branch

  • This PR targets dev, not main.

Linked Issue

Fixes #3852

Type of Change

  • Bug fix (non-breaking, fixes a confirmed issue)
  • New feature (non-breaking, adds new behaviour)
  • Breaking change (changes or removes existing behaviour)
  • Refactor / cleanup (behaviour unchanged)
  • Documentation only
  • CI / tooling / configuration

Checklist

  • I searched open issues and open PRs and this is not a duplicate.
  • This PR targets dev
  • My changes are limited to the scope described above, no unrelated refactors or whitespace churn.

How to Test

python -m pytest tests/test_load_features_permission_error.py -q   # 1 passed
python -m py_compile src/settings.py                               # ok

The test monkeypatches open to raise PermissionError for features.json and asserts load_features() returns DEFAULT_FEATURES. Verified it raises against current dev.

Visual / UI changes

None, backend only.

load_settings() already catches PermissionError, but load_features() caught only
FileNotFoundError/JSONDecodeError/ValueError. An existing-but-unreadable
data/features.json (e.g. root-owned after a deploy) therefore raised instead of
falling back to DEFAULT_FEATURES, taking down GET /api/auth/features and anything
that reads feature flags. Add PermissionError to the except tuple to match
load_settings().

Adds tests/test_load_features_permission_error.py.
@github-actions github-actions Bot added the ready for review Description complete — ready for maintainer review label Jun 10, 2026

@alteixeira20 alteixeira20 left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGFM. This is a narrow degraded-state fix: load_features() now matches the existing fallback behavior for missing/invalid feature config when features.json is unreadable due to PermissionError.

The regression test is focused, normal CI is green, and the PR does not broaden scope beyond the intended fallback.

@alteixeira20
alteixeira20 merged commit f5c1eb4 into odysseus-dev:dev Jun 11, 2026
14 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

ready for review Description complete — ready for maintainer review

Projects

None yet

Development

Successfully merging this pull request may close these issues.

load_features() raises on an unreadable features.json instead of using defaults

2 participants