Skip to content

Fix custom accept error message not shown for unsupported file type in file input - #1928

Open
farhaharoon0931-eng wants to merge 1 commit into
adobe:masterfrom
farhaharoon0931-eng:fix/fileinput-accept-custom-error-message
Open

Fix custom accept error message not shown for unsupported file type in file input#1928
farhaharoon0931-eng wants to merge 1 commit into
adobe:masterfrom
farhaharoon0931-eng:fix/fileinput-accept-custom-error-message

Conversation

@farhaharoon0931-eng

Copy link
Copy Markdown

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 pushed a commit that referenced this pull request Jul 31, 2026
…ported file type

The File Attachment (fileinput) widget's invalidMessage() looked up the custom
unsupported-file-type message under constraintMessages.invalidMimeType, which is
not a real constraint key. The authorable key is `accept` (ConstraintType.ACCEPT),
backed by the acceptMessage dialog property, so the custom message was always
undefined and a generic fallback was shown. The maxFileSize custom message worked
because it already uses the correct key.

Fix: read constraintMessages.accept for the MIMETYPE case, in both the ui.frontend
source (FormFileInputWidgetBase.js) and the v4 clientlib copy (fileinputwidget.js).
Backport of master PR #1928 to release/650.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
mayankjindalmj pushed a commit that referenced this pull request Jul 31, 2026
…ed file type

Adds the extra Cypress coverage from #1928, adapted to release/650: upload an
unsupported-type file (sample.svg) to fileinput3 (accept=[application/pdf], now with
an acceptMessage) and assert the alert equals constraintMessages.accept.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
mayankjindalmj added a commit that referenced this pull request Aug 4, 2026
…ile Attachment (#1940)

* FORMS-26813 : backport PR #1928 - show custom acceptMessage for unsupported file type

The File Attachment (fileinput) widget's invalidMessage() looked up the custom
unsupported-file-type message under constraintMessages.invalidMimeType, which is
not a real constraint key. The authorable key is `accept` (ConstraintType.ACCEPT),
backed by the acceptMessage dialog property, so the custom message was always
undefined and a generic fallback was shown. The maxFileSize custom message worked
because it already uses the correct key.

Fix: read constraintMessages.accept for the MIMETYPE case, in both the ui.frontend
source (FormFileInputWidgetBase.js) and the v4 clientlib copy (fileinputwidget.js).
Backport of master PR #1928 to release/650.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

* FORMS-26813 : add test scenario for custom acceptMessage on unsupported file type

Adds the extra Cypress coverage from #1928, adapted to release/650: upload an
unsupported-type file (sample.svg) to fileinput3 (accept=[application/pdf], now with
an acceptMessage) and assert the alert equals constraintMessages.accept.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>

---------

Co-authored-by: Mayank Jindal <mayankjindal@adobe.com>
Co-authored-by: Claude Opus 4.8 <noreply@anthropic.com>
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