Skip to content

Show custom acceptMessage for unsupported file type in File Attachment - #1941

Closed
mayankjindalmj wants to merge 1 commit into
masterfrom
FORMS-26813-fileinput-accept-message
Closed

Show custom acceptMessage for unsupported file type in File Attachment#1941
mayankjindalmj wants to merge 1 commit into
masterfrom
FORMS-26813-fileinput-accept-message

Conversation

@mayankjindalmj

@mayankjindalmj mayankjindalmj commented Jul 31, 2026

Copy link
Copy Markdown
Contributor

Original PR #1928 couldn't be merged due to a fork.

Summary

  • The file-input widget's invalidMessage() looked up constraintMessages.invalidMimeType for the "unsupported file type" alert, but invalidMimeType is not an authorable constraint message key — the schema only exposes constraintMessages.accept (backed by the acceptMessage dialog property, see AbstractBaseImpl.ConstraintMessages#getAcceptConstraintMessage).
  • As a result, the custom message authors configure for file-type validation was always ignored in favor of the generic fallback string, while the analogous maxFileSize custom message worked correctly since its key matched (constraintMessages.maxFileSize).
  • Fixed in both the webpack source (ui.frontend/src/view/FormFileInputWidgetBase.js) and the apps clientlib copy (ui.af.apps/.../fileinput/v4/fileinput/clientlibs/site/js/fileinputwidget.js).

Root cause (reproduced live)

File uploaded Alert before fix Alert after fix
Oversized file (allowed type) Custom maxFileSize message ✅ unchanged ✅
Unsupported file type Generic fallback message ❌ (ignored author's acceptMessage) Custom accept/acceptMessage text ✅

Test plan

  • node --check on both modified JS files
  • Added Cypress test should display a custom error message configured by the user for unsupported file type in fileinputv4.runtime.cy.js, mirroring the existing maxFileSize custom-message test
  • Added acceptMessage to the fileinput7 fixture field in the IT sample content used by that spec
  • Full Cypress IT run against a live AEM instance (not run in this environment — no AEM instance available)

…n file input

The file-input widget's invalidMessage() looked up
constraintMessages.invalidMimeType for the unsupported-file-type alert,
but invalidMimeType is not an authorable constraint message key - the
schema only exposes constraintMessages.accept (backed by the
acceptMessage dialog property). As a result the custom message
authors configure for file type validation was always ignored in
favor of the generic fallback string, while the analogous
maxFileSize custom message worked correctly since its key matched.

Updated both the webpack source (ui.frontend) and the apps clientlib
copy (ui.af.apps) to read constraintMessages.accept, and added a
Cypress assertion mirroring the existing maxFileSize custom-message
test.
@mayankjindalmj
mayankjindalmj marked this pull request as ready for review July 31, 2026 09:33
@mayankjindalmj

mayankjindalmj commented Aug 3, 2026

Copy link
Copy Markdown
Contributor Author

Closing in favor of the dev-targeted PR (same fix + test, cherry-picked).

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants