Skip to content

fix: handle non-numeric identity_pk in IdentityFeatureStateViewSet#7485

Open
SAY-5 wants to merge 1 commit into
Flagsmith:mainfrom
SAY-5:fix/identity-pk-non-numeric
Open

fix: handle non-numeric identity_pk in IdentityFeatureStateViewSet#7485
SAY-5 wants to merge 1 commit into
Flagsmith:mainfrom
SAY-5:fix/identity-pk-non-numeric

Conversation

@SAY-5
Copy link
Copy Markdown

@SAY-5 SAY-5 commented May 12, 2026

Fixes #7361.

/api/v1/environments/<key>/identities/<identity_pk>/featurestates/ crashes with ValueError when identity_pk is non-numeric (e.g. an external identifier passed through by mistake), because Django's ORM tries to coerce it to int for the identity__pk lookup.

This mirrors the approach in #7443: validate the value up front and return an empty queryset for non-numeric ids, so the API responds 200 with [] instead of 500.

Contributes to #6809.

Validate identity_pk before passing to the ORM filter so that
non-numeric URL captures return an empty queryset instead of raising
ValueError in the model field.

Contributes to Flagsmith#6809
Fixes Flagsmith#7361

Signed-off-by: say <say.apm35@gmail.com>
@SAY-5 SAY-5 requested a review from a team as a code owner May 12, 2026 03:16
@SAY-5 SAY-5 requested review from khvn26 and removed request for a team May 12, 2026 03:16
Copy link
Copy Markdown

@claude claude Bot left a comment

Choose a reason for hiding this comment

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

Claude Code Review

This pull request is from a fork — automated review is disabled. A repository maintainer can comment @claude review to run a one-time review.

@vercel
Copy link
Copy Markdown

vercel Bot commented May 12, 2026

@SAY-5 is attempting to deploy a commit to the Flagsmith Team on Vercel.

A member of the Team first needs to authorize it.

@github-actions github-actions Bot added the api Issue related to the REST API label May 12, 2026
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.

API crash because of bad URL parameters

1 participant