Problem/Motivation

This problem occurs with the inline_form_errorsmodule enabled and a Link field widget configured to accept external URLs. When a validation constraint error is produced by the Link field that error is shown inline in the field three times: once for the entire widget, once for the uri element, and once for the title element.

Steps to reproduce

  1. Enable the inline_form_errors module.
  2. Add a link field to the Article content type. Set the "Allowed link type" to external links only. Set the "Allow link text" to optional.
  3. Attempt to create a new article. Enter 'test://example.com' for the URL field and 'Link' for the text fiield.
  4. Submit the form.

Expected Result

There should be a single inline form error for the entire Link field.

Actual Result

There are three inline form errors for the Link field.

Note: the issue is not reproducible with the example URL shown in the image below, /example.com. That will trigger the element's HTML5 validation error instead.
Invalid message

Proposed resolution

Set the violation error's path to the uri element in the validation constraint classes.

Remaining tasks

Update the tests for the inline form errors. Review. Feedback. Commit.

User interface changes

Introduced terminology

API changes

Data model changes

Release notes snippet

Issue fork drupal-3077149

Command icon Show commands

Start within a Git clone of the project using the version control instructions.

Or, if you do not have SSH keys set up on git.drupalcode.org:

Comments

abhaisasidharan created an issue. See original summary.

jidrone’s picture

Assigned: abh.ai » Unassigned
Status: Active » Needs review
StatusFileSize
new2.03 KB

The problem was the Contraint Validator wasn't using the atPath method, and the widget didn't get the error element for subfields.

Version: 8.8.x-dev » 8.9.x-dev

Drupal 8.8.0-alpha1 will be released the week of October 14th, 2019, which means new developments and disruptive changes should now be targeted against the 8.9.x-dev branch. (Any changes to 8.9.x will also be committed to 9.0.x in preparation for Drupal 9’s release, but some changes like significant feature additions will be deferred to 9.1.x.). For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 8.9.x-dev » 9.1.x-dev

Drupal 8.9.0-beta1 was released on March 20, 2020. 8.9.x is the final, long-term support (LTS) minor release of Drupal 8, which means new developments and disruptive changes should now be targeted against the 9.1.x-dev branch. For more information see the Drupal 8 and 9 minor version schedule and the Allowed changes during the Drupal 8 and 9 release cycles.

Version: 9.1.x-dev » 9.2.x-dev

Drupal 9.1.0-alpha1 will be released the week of October 19, 2020, which means new developments and disruptive changes should now be targeted for the 9.2.x-dev branch. For more information see the Drupal 9 minor version schedule and the Allowed changes during the Drupal 9 release cycle.

Version: 9.2.x-dev » 9.3.x-dev

Drupal 9.2.0-alpha1 will be released the week of May 3, 2021, which means new developments and disruptive changes should now be targeted for the 9.3.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

larowlan’s picture

This issue was today's Bugsmash triage target

The patch looks good, we just need some automated testing for this to ensure it stays fixed.

larowlan’s picture

Wrong tag

quietone’s picture

Issue summary: View changes

I tested this on Drupal 9.3.x, standard install and was not able to reproduce the problem.

  1. Add link field to Article
  2. Set to external links only
  3. Then add an article
  4. Enter /example.com in the link field, save
  5. Then get a message to 'enter a valid URL'. There were no three errors listed.

I also tried on 8.9.19-dev with the same results.

larowlan’s picture

Status: Needs review » Postponed (maintainer needs more info)
Issue tags: +Needs steps to reproduce

@jidrone @abhaisasidharan - are you able to confirm this is no longer an issue

Version: 9.3.x-dev » 9.4.x-dev

Drupal 9.3.0-rc1 was released on November 26, 2021, which means new developments and disruptive changes should now be targeted for the 9.4.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.4.x-dev » 9.5.x-dev

Drupal 9.4.0-alpha1 was released on May 6, 2022, which means new developments and disruptive changes should now be targeted for the 9.5.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

Version: 9.5.x-dev » 10.1.x-dev

Drupal 9.5.0-beta2 and Drupal 10.0.0-beta2 were released on September 29, 2022, which means new developments and disruptive changes should now be targeted for the 10.1.x-dev branch. For more information see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

kristen pol’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)
Issue tags: -Needs manual testing, -Needs tests +DrupalSouth

As part of the Bug Smash Initiative, we are triaging issues that are marked "Postponed (maintainer needs more info)". This issue was marked "Postponed (maintainer needs more info)" a year ago.

Like @quietone in #9, I also was unable to reproduce the issue. I tested with the same steps as in #9 other than I used the page content type.

Since neither I nor @quietone could reproduce this issue and since there weren't other steps to reproduce the issue provided since the issue was postponed a year ago, I'm marking the issue "Closed (cannot reproduce)". If anyone can provide complete steps to reproduce the issue (starting from "Install Drupal core"), document those steps in the issue summary and set the issue status back to "Active" [or "Needs Work" if it has a patch, etc.].

Thanks!

gaurav_manerkar’s picture

StatusFileSize
new251.3 KB

I am able to reproduce the issue on Drupal 9.4.x.

Steps to reproduce the issue:

  1. Add link field to Article content type
  2. Set "Allowed link type" to external links only
  3. Set "Allow link text" to optional
  4. Then add an article
  5. Enter 'test://example.com' for the URL field and 'Link' for the text fiield
  6. Submit
  7. Three errors are getting listed
gaurav_manerkar’s picture

Status: Closed (cannot reproduce) » Active
gaurav_manerkar’s picture

gaurav_manerkar’s picture

gaurav_manerkar’s picture

Status: Active » Needs review
gaurav_manerkar’s picture

Status: Needs review » Needs work
gaurav_manerkar’s picture

Fixed unit tests.

gaurav_manerkar’s picture

Status: Needs work » Needs review
smustgrave’s picture

Status: Needs review » Postponed (maintainer needs more info)
Issue tags: +Needs issue summary update, +Needs steps to reproduce

This issue is being reviewed by the kind folks in Slack, #need-reveiw-queue. We are working to keep the size of Needs Review queue [2700+ issues] to around 200, following Review a patch or merge require as a guide.

Moving to PNMI for an updated issue summary specifically steps to reproduce.
Tried testing in 10.1.x and am not seeing the error.

smustgrave’s picture

Version: 10.1.x-dev » 11.x-dev

Drupal core is moving towards using a “main” branch. As an interim step, a new 11.x branch has been opened, as Drupal.org infrastructure cannot currently fully support a branch named main. New developments and disruptive changes should now be targeted for the 11.x branch, which currently accepts only minor-version allowed changes. For more information, see the Drupal core minor version schedule and the Allowed changes during the Drupal core release cycle.

smustgrave’s picture

Status: Postponed (maintainer needs more info) » Closed (cannot reproduce)

If still a valid bug please reopen updating issue summary per #24

Thanks!

amateescu’s picture

Issue summary: View changes
Status: Closed (cannot reproduce) » Needs review
Issue tags: -Needs issue summary update, -Needs steps to reproduce

What the issue summary didn't mention is that this is only reproducible with the Inline form errors module enabled. Updated the IS.

smustgrave’s picture

Status: Needs review » Needs work

Thanks for updating!

If that's the case then the tests will need to be updated to check for that.

dcam’s picture

Title: Invalid path error message is displayed three times in link widget for external link » Duplicate inline form errors in external Link widgets
Issue summary: View changes
Issue tags: +Needs tests

Added the issue summary template. Added the Needs Tests tag because the existing tests need to be updated to check for those specifically.

dcam’s picture

Issue tags: -DrupalSouth

The patch from #22 was converted to an MR. The changes to LinkNotExistingInternalConstraintValidatorTest did not seem to be relevant anymore. No other test changes have been made.

dcam’s picture

The original proposed changes must be updated because the arrayPropertyPath property was deprecated and removed. Here's the change record: https://www.drupal.org/node/3307919.

dcam’s picture

Title: Duplicate inline form errors in external Link widgets » [PP-1] Duplicate inline form errors in external Link widgets
Status: Needs work » Postponed

We need to repair a test in LinkNotExistingInternalConstraintValidatorTest to test this properly. This issue is postponed on #3542967: Bad test in LinkNotExistingInternalConstraintValidatorTest.

dcam’s picture

Title: [PP-1] Duplicate inline form errors in external Link widgets » Duplicate inline form errors in external Link widgets
Status: Postponed » Needs work

The test fix was committed. This is unblocked now.

dcam’s picture

Status: Needs work » Needs review
Issue tags: -Needs tests

I modified the constraint validator Unit tests to ensure the error path is set to the uri element. I also added an entire test for the LinkTypeConstraintValidator which I then partially added to the pending bug fix in #3387013: Check LinkItemInterface::isEmpty() before validating. So when one of these two issues gets committed the other will need to be rebased and have the changes merged in.

smustgrave’s picture

Status: Needs review » Postponed

Since #3387013: Check LinkItemInterface::isEmpty() before validating is RTBC lets postpone this till that lands so it doesn't interrupt that one getting in.

dcam’s picture

Status: Postponed » Needs review

I'm prioritizing this over #3387013: Check LinkItemInterface::isEmpty() before validating because that one's no longer RTBC. This MR has the more complete LinkTypeConstraintValidatorTest. And IMO it's the more serious bug.

smustgrave’s picture

Status: Needs review » Reviewed & tested by the community
StatusFileSize
new21.27 KB
new20.78 KB

Before

before

After

after

Tested manually following the steps in the summary and I was able to reproduce.
After applying the MR the fix appears to be working

MR LGTM

  • catch committed 2e64e608 on 11.x
    Issue #3077149 by jidrone, larowlan, quietone, gaurav_manerkar,...
catch’s picture

Status: Reviewed & tested by the community » Fixed

OK this is more change than I expected from the issue title, but it's really the same change multiple times + supporting code + very good test coverage.

Committed/pushed to 11.x, thanks!

Now that this issue is closed, please review the contribution record.

As a contributor, attribute any organization that helped you, or if you volunteered your own time.

Maintainers, please credit people who helped resolve this issue.

Status: Fixed » Closed (fixed)

Automatically closed - issue fixed for 2 weeks with no activity.