Skip to content

fix(frontend): show validation errors on the Hugging Face field and drop two redundant guards - #7787

Merged
aglinxinyuan merged 1 commit into
apache:mainfrom
aglinxinyuan:fix/hugging-face-show-error
Aug 19, 2026
Merged

fix(frontend): show validation errors on the Hugging Face field and drop two redundant guards#7787
aglinxinyuan merged 1 commit into
apache:mainfrom
aglinxinyuan:fix/hugging-face-show-error

Conversation

@aglinxinyuan

Copy link
Copy Markdown
Contributor

What changes were proposed in this PR?

Three template fixes. The first is a real user-facing bug; the other two are safe no-ops.

1. The Hugging Face model field never showed validation errors.

- *ngIf="props.showError && formControl.errors">
+ *ngIf="showError && formControl.errors">

showError is a getter on @ngx-formly's FieldType (templates/field.type.d.ts:25), a sibling of get props()not a props field. The only other showError declarations in formly are predicate functions (FormlyFormOptions.showError, FormlyConfig.extras.showError). So props.showError was permanently undefined and <formly-validation-message> could never render. It typechecked only because formly's props type carries an index signature, which is why it went unnoticed.

The two working siblings in this codebase already use the bare getter: common/formly/object.type.ts:23 and multischema.type.ts:24.

2. console-frame.component.html: removed a shadowed duplicate template pair. #checkedTemplate was declared at lines 36 and 53, #unCheckedTemplate at 41 and 58, with both nz-switches referencing the same two names. First declaration wins, so the second pair was unreachable — and both bodies were byte-identical.

3. dataset-detail.component.html: removed a redundant conjunct. Line 585's userHasWriteAccess() && is dominated by the enclosing nz-collapse (line 452), already gated on userDatasetAccessLevel === "WRITE" — exactly what that method returns (dataset-detail.component.ts:560-562). Both read the same field, so they cannot disagree even at runtime.

The fix is pinned by a test that fails without it

A validation message describe in hugging-face.component.spec.ts asserts both directions. With the template reverted to props.showError, that test fails (1 failed | 86 passed); with the fix, 87 pass.

The sharpest detail: on the unfixed template, expect(component.showError).toBe(true) passes on the line above while the DOM query returns null. The getter says to show the error and the template ignores it — which is precisely the bug, and precisely why no existing test caught it.

One fixture change was required, and it is fixture infidelity rather than fallout

Applying the fix initially failed 78 tests with TypeError: this.options.showError is not a function, because the spec's field literals supplied options: { detectChanges: vi.fn() } only. In production FormlyForm always fills in options.showError and options.fieldChanges. Those fixtures were therefore modelling a state formly never produces. Added one buildFormlyOptions() helper and used it at the six existing options: literals; no test asserted on options.detectChanges, so behaviour is unchanged.

Items 2 and 3 are verified as behaviour-preserving

For console-frame, rather than assume the duplicate was inert, the existing settings-dropdown test was temporarily instrumented to dump innerHTML of both switches in both on and off states, run against the original and the fixed template, and diffed. The only delta is Angular's generated style-scope id (_ngcontent-a-c3896271133_ngcontent-a-c2948443161), a template-content hash stamped consistently on DOM and CSS. Normalising it, the rendered on/off content is identical. The instrumentation was reverted and is not in this diff.

For dataset-detail, the suite passes 173/173 both with and without the change — no test outcome moves, which is what makes it a safe cleanup rather than a behaviour change. The one case that looked risky (offers the creator only once there is something to commit) uses the merging render helper, so userDatasetAccessLevel stays "WRITE" across its second render.

Verification

  • hugging-face + console-frame + dataset-detail in one run: 288 passed (288).
  • operator-property-edit-frame + formly-config as regression cover for the formly options path: 207 passed | 1 skipped.
  • npx ng build exits 0 with Browser application bundle generation complete and zero [ERROR] lines — worth running here because ng test and tsc --noEmit both miss Angular template diagnostics.
  • yarn format:ci exits 0.

Any related issues, documentation, discussions?

Closes #7786

How was this PR tested?

npx ng test --watch=false --include="**/hugging-face.component.spec.ts" --include="**/console-frame.component.spec.ts" --include="**/dataset-detail.component.spec.ts"
 Test Files  3 passed (3)
      Tests  288 passed (288)

Was this PR authored or co-authored using generative AI tooling?

Generated-by: Claude Code (Opus 5)

Copilot AI lite review requested due to automatic review settings August 19, 2026 09:29

Copilot AI left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@github-actions github-actions Bot added fix frontend Changes related to the frontend GUI labels Aug 19, 2026
@Yicong-Huang Yicong-Huang added the release/v1.2 back porting to release/v1.2 label Aug 19, 2026
@github-actions
github-actions Bot requested a review from xuang7 August 19, 2026 11:01
@github-actions

Copy link
Copy Markdown
Contributor

Backport auto-label report

This fix: PR was checked against each actively-supported release branch. release/* labels drive the post-merge backport, so add or remove one to change where this fix lands.

Release branch Analysis
release/v1.2 Change detected on this branch — label added; this fix is queued to backport here. Requested review from @xuang7.

Auto-label run.

@github-actions

Copy link
Copy Markdown
Contributor

Automated Reviewer Suggestions

Based on the git blame history of the changed files, we recommend the following reviewers:

  • Contributors with relevant context: @xuang7, @juliethecao, @mengw15
    You can notify them by mentioning @xuang7, @juliethecao, @mengw15 in a comment.

@codecov-commenter

codecov-commenter commented Aug 19, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 91.25%. Comparing base (bf0e777) to head (1e8dcb8).
⚠️ Report is 1 commits behind head on main.

Additional details and impacted files
@@             Coverage Diff              @@
##               main    #7787      +/-   ##
============================================
+ Coverage     91.24%   91.25%   +0.01%     
  Complexity     4469     4469              
============================================
  Files          1171     1171              
  Lines         47115    47112       -3     
  Branches       5286     5285       -1     
============================================
+ Hits          42992    42994       +2     
+ Misses         2448     2444       -4     
+ Partials       1675     1674       -1     
Flag Coverage Δ *Carryforward flag
access-control-service 81.00% <ø> (ø) Carriedforward from bf0e777
agent-service 98.62% <ø> (ø) Carriedforward from bf0e777
amber 87.99% <ø> (ø) Carriedforward from bf0e777
computing-unit-managing-service 73.67% <ø> (ø) Carriedforward from bf0e777
config-service 86.73% <ø> (ø) Carriedforward from bf0e777
file-service 68.90% <ø> (ø) Carriedforward from bf0e777
frontend 92.66% <100.00%> (+0.02%) ⬆️
notebook-migration-service 83.74% <ø> (ø) Carriedforward from bf0e777
pyamber 97.57% <ø> (ø) Carriedforward from bf0e777
workflow-compiling-service 77.19% <ø> (ø) Carriedforward from bf0e777

*This pull request uses carry forward flags. Click here to find out more.

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@xuang7 xuang7 removed the release/v1.2 back porting to release/v1.2 label Aug 19, 2026

@xuang7 xuang7 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM!

@aglinxinyuan
aglinxinyuan added this pull request to the merge queue Aug 19, 2026
Merged via the queue into apache:main with commit 5f95b67 Aug 19, 2026
45 of 52 checks passed
@aglinxinyuan
aglinxinyuan deleted the fix/hugging-face-show-error branch August 19, 2026 23:13
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

fix frontend Changes related to the frontend GUI

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Hugging Face field never shows validation errors, plus two redundant template guards

5 participants