Skip to content

fix(users): Use project_id for HybridCloudForeignKey filter#107746

Merged
JoshFerge merged 3 commits intomasterfrom
jferg/fix-user-option-project-id
Feb 6, 2026
Merged

fix(users): Use project_id for HybridCloudForeignKey filter#107746
JoshFerge merged 3 commits intomasterfrom
jferg/fix-user-option-project-id

Conversation

@JoshFerge
Copy link
Member

@JoshFerge JoshFerge commented Feb 5, 2026

Summary

Found during mypy / django-stubs upgrade in #107710.

Changes .filter(project=project) to .filter(project_id=project.id) in UserOptionManager.unset_value(). The project field is a HybridCloudForeignKey, which doesn't support passing a model instance directly — use the _id suffix instead.'

I believe that this code never ran in prod? As the test written breaks with code in master, passes on this branch.

Found during mypy / django-stubs upgrade in #107710.
@github-actions github-actions bot added the Scope: Backend Automatically applied to PRs that change backend components label Feb 5, 2026
@JoshFerge JoshFerge marked this pull request as ready for review February 6, 2026 15:01
Verifies that unset_value correctly deletes user options scoped to a
project using the HybridCloudForeignKey project_id field.
This isn't implemented for user-organization scoped options yet, because it hasn't been needed.
"""
self.filter(user=user, project=project, key=key).delete()
self.filter(user=user, project_id=project.id, key=key).delete()
Copy link
Member

Choose a reason for hiding this comment

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

Why is this preferred?

@JoshFerge JoshFerge merged commit 2bba5f8 into master Feb 6, 2026
82 checks passed
@JoshFerge JoshFerge deleted the jferg/fix-user-option-project-id branch February 6, 2026 16:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Scope: Backend Automatically applied to PRs that change backend components

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants