Closed (fixed)
Project:
Address
Version:
2.0.4
Component:
Code
Priority:
Normal
Category:
Bug report
Assigned:
Unassigned
Reporter:
Created:
4 Oct 2025 at 08:19 UTC
Updated:
13 Nov 2026 at 03:00 UTC
Jump to comment: Most recent
If the AddressFormatConstraintValidator can't find a subfield label for a given violation, it will not set a value at all. This can lead to fatal errors in some cases.
In AddressFormatConstraintValidator, if a label is not defined, fallback to using the field label in the message.
| Comment | File | Size | Author |
|---|---|---|---|
| feeds.feed_type.property_import.yml | 3.24 KB | malcomio |
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
Comment #2
malcomio commentedThis error comes from the address module's AddressFormatConstraint, so possibly that module is the source of the error?
Comment #3
malcomio commentedHaving debugged further, the problem is that AddressFormatConstraintValidator does not always
In my case the administrativeArea and dependentLocality field have no labels, so the violation doesn't specify them properly.
Comment #5
malcomio commentedComment #6
cspitzlayA customer of ours triggered this crash yesterday, too.
I think this happens when working with non-empty address fields for country codes that do not have them as part of their country-specific format / do not specify a type for it. In my customer's case that's country code 'IT' and the dependent_locality field.
I guess it is not possible to create this situation via the standard Commerce UI because it will automatically remove any fields that do not make sense for the selected country. But programmatically this case is possible.
I think that before PHP 8.4 or and/or with a previous version of the module this issue was silently ignored because PHP would happily convert the value NULL into an empty string which resulted in a non-helpful error message, but no crash.
Comment #7
cspitzlayI looked at the suggested change and tested it. It fixes the issue for me. It cannot provide a label out of thin air, of course, but at least it prevents the type error and the resulting error message, e.g. 'dependentLocality field must be blank.' is helpful for the developer who reads it. In the UI this case should not happen in the first place.
Comment #8
malcomio commentedI think when we saw this it was on PHP 8.3
Comment #9
cspitzlayI definitely recall seeing the message without a field name, i.e. at the time it did not crash.
But I am not sure what combination of PHP and module versions we had back then.
Comment #12
dwwThanks malcomio and cspitzlay for working on this. Normally, I'd both ask for tests, and complain that changes like this tend to mask deeper bugs and make them harder to debug in the future. However, in this case, it's pretty obvious that if there's no label (because we have a value for something outside a country's default address format or whatever) it's better to fall back to the field name than to cause an error without a label at all.
I rebased this against the latest 2.1.x branch and removed commit c64e9809 which was actively harming the ease of reviewing and committing this fix. tBkoT please don't do that again to any other issue. If we're going to do any code style refactoring, it'll be in a separate issue, not as "cleanup while we're at it" in another issue (bug, feature or task). Thanks.
Comment #13
dwwComment #16
dwwMerged to 2.1.x, cherry picked to 2.0.x and pushed. Thanks!