Skip to content

fix: return 404 for missing versioning parents#7880

Draft
Dexter2099 wants to merge 1 commit into
Flagsmith:mainfrom
Dexter2099:fix-6556-nested-permission-404
Draft

fix: return 404 for missing versioning parents#7880
Dexter2099 wants to merge 1 commit into
Flagsmith:mainfrom
Dexter2099:fix-6556-nested-permission-404

Conversation

@Dexter2099

Copy link
Copy Markdown

Changes

  • Return 404 when feature-versioning permission checks encounter a missing nested environment or feature parent.
  • Add focused regression coverage for missing parent resources in the feature-versioning permission classes.

Root cause

DRF runs permission checks before the feature-versioning view initial() methods. These permission classes used direct Environment.objects.get(...) / Feature.objects.get(...) lookups, so missing nested parents could raise raw DoesNotExist exceptions instead of returning a 404 response.

Fixes #6556

Testing

  • uv run ruff check features/versioning/permissions.py tests/unit/features/versioning/test_unit_versioning_permissions.py
  • PYTEST_DISABLE_PLUGIN_AUTOLOAD=1 DATABASE_URL=postgresql://postgres:password@localhost:5433/flagsmith ANALYTICS_DATABASE_URL=postgresql://postgres:password@localhost:5433/analytics uv run pytest -p django -p xdist.plugin -p pytest_mock tests/unit/features/versioning/test_unit_versioning_permissions.py -n0

Note: I used the explicit pytest plugins above because local Windows plugin autoload hits a pyreadline compatibility issue. The broader versioning view module also hits a Windows-only gunicorn/fcntl import path in this local environment.

@vercel

vercel Bot commented Jun 25, 2026

Copy link
Copy Markdown

@Dexter2099 is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

api Issue related to the REST API

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Nested permissions not returning 404 for missing parent entities

1 participant