Repository navigation
[bug] Require only 'view' permission to read model metadata - #13348
Merged
SchrodingersGat merged 1 commit intoNov 23, 2026
Merged
Conversation
ContentTypePermission works out 'view' for safe methods and 'change' otherwise, but its fallback for models without check_permission() (e.g. Part, StockItem) still passed a hardcoded 'change'. Reading metadata via the generic metadata endpoint therefore required 'change' permission, unlike the model's own detail endpoint, which needs 'view'. Co-Authored-By: Claude Opus 5.5 <[email protected]>
👷 Deploy request for inventree-web-pui-preview pending review.Visit the deploys page to approve it
|
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## master #13348 +/- ##
=======================================
Coverage 90.41% 90.41%
=======================================
Files 907 907
Lines 83834 83844 +10
Branches 4308 4308
=======================================
+ Hits 75795 75808 +13
+ Misses 7025 7022 -3
Partials 1014 1014
Flags with carried forward coverage won't be shown. Click here to find out more.
🚀 New features to boost your workflow:
|
Member
|
@LeonKie thanks for the fix! |
Contributor
💚 All backports created successfully
Questions ?Please refer to the Backport tool documentation and see the Github Action logs for details |
SchrodingersGat
pushed a commit
that referenced
this pull request
Nov 24, 2026
…13350) ContentTypePermission works out 'view' for safe methods and 'change' otherwise, but its fallback for models without check_permission() (e.g. Part, StockItem) still passed a hardcoded 'change'. Reading metadata via the generic metadata endpoint therefore required 'change' permission, unlike the model's own detail endpoint, which needs 'view'. (cherry picked from commit 3744e74) Co-authored-by: Leon Kiesgen <[email protected]> Co-authored-by: Claude Opus 5.5 <[email protected]>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
Reading an object's metadata through the generic metadata endpoint (
GET /api/metadata/<model>/<pk>/) requires change permission for models without acheck_permission()method, e.g.PartorStockItem. A user or API token with only view permission on Parts gets:although the same user can read the part itself on its detail endpoint. Read-only integrations (e.g. a read-only CI token that compares metadata) therefore need write permission.
Cause
ContentTypePermission.has_object_permissionworks out the required permission ('view'for safe methods,'change'otherwise) and passes it tocheck_permission(), but its fallback for models without one still passes a hardcoded'change':Fix
Pass the computed
permissioninstead, so reads need view and writes still need change. The behaviour for ignore-listed models and models withcheck_permission()is unchanged.I did not bump
INVENTREE_API_VERSION; happy to add an entry if you consider this an API change.