Skip to content

Fix validation of dependent serializer fields - #12871

Merged
SchrodingersGat merged 1 commit into
inventree:masterfrom
ledvinap:fix/dependent-field-validation
Sep 17, 2026
Merged

SchrodingersGat merged 1 commit into
inventree:masterfrom
ledvinap:fix/dependent-field-validation

Conversation

@ledvinap

@ledvinap ledvinap commented Sep 17, 2026 •

Copy link
Copy Markdown
Contributor

AI generated, as usual:

DependentField validates its wrapper but calls only the child’s to_internal_value(). That skips the child’s own validators and serializer-level validate(). Calling child.run_validation() restores the complete validation process.

A concrete use is machine printer options: the selected printer driver supplies a serializer dynamically. For example, a driver could reject an incompatible combination:

def validate(self, attrs):
    if attrs['auto_cut'] and attrs['media'] == 'continuous':
        raise serializers.ValidationError(
            'Automatic cutting is unavailable for continuous media.'
        )
    return attrs

Both individual fields are valid, but their combination is rejected only by validate(). Before this fix, that check never runs and the API can dispatch the print task.

That combination is illustrative; the actual regression test supplies a rejecting driver serializer and demonstrates HTTP 201 before the fix, HTTP 400 with no task dispatch afterward.

@netlify

netlify Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

✅ Deploy Preview for inventree-web-pui-preview canceled.

Name Link
🔨 Latest commit e4d6c8d
🔍 Latest deploy log https://app.netlify.com/projects/inventree-web-pui-preview/deploys/6aabfa8d0b5fd700073fafe0

@codecov

codecov Bot commented Sep 17, 2026 •

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 86.79%. Comparing base (3a0ade3) to head (e4d6c8d).
⚠️ Report is 3 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master   #12871      +/-   ##
==========================================
- Coverage   87.26%   86.79%   -0.47%     
==========================================
  Files        1502     1502              
  Lines      102169   103054     +885     
  Branches    11661    11661              
==========================================
+ Hits        89156    89447     +291     
- Misses      12948    13542     +594     
  Partials       65       65              
Flag Coverage Δ
backend 91.89% <100.00%> (+0.01%) ⬆️

Flags with carried forward coverage won't be shown. Click here to find out more.

Components Coverage Δ
Backend Apps 91.52% <100.00%> (-1.02%) ⬇️
Backend General 88.17% <ø> (-6.56%) ⬇️
Frontend 79.82% <ø> (ø)
🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

@SchrodingersGat SchrodingersGat added bug Identifies a bug which needs to be addressed report Report/Label generation backport Apply this label to a PR to enable auto-backport action backport-to-1.5.x labels Sep 17, 2026
@SchrodingersGat SchrodingersGat added this to the 1.6.0 milestone Sep 17, 2026
@SchrodingersGat
SchrodingersGat merged commit b9c7c24 into inventree:master Sep 17, 2026
50 of 52 checks passed
@SchrodingersGat

Copy link
Copy Markdown
Member

@ledvinap thanks for the fix

@github-actions

Copy link
Copy Markdown
Contributor

💚 All backports created successfully

Status Branch Result
✅ 1.5.x

Questions ?

Please refer to the Backport tool documentation and see the Github Action logs for details

SchrodingersGat added a commit that referenced this pull request Sep 19, 2026
(cherry picked from commit b9c7c24)

Co-authored-by: Petr Ledvina <[email protected]>
Co-authored-by: Oliver <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport Apply this label to a PR to enable auto-backport action backport-to-1.5.x bug Identifies a bug which needs to be addressed report Report/Label generation

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants