revert: "fix(checkout): guard invalid carrier settings" (#513) - #520
Closed
NabDevs wants to merge 3 commits into
Closed
revert: "fix(checkout): guard invalid carrier settings" (#513)#520NabDevs wants to merge 3 commits into
NabDevs wants to merge 3 commits into
Conversation
* Guard carrier settings * test: clean carrier guard * fix: validate carrier entries * fix: ignore malformed carrier settings * refactor: simplify carrier settings guard
Reverts squash commit 393ad70. The change was merged prematurely and still needs to be tested. Temporary revert to keep main releasable (the scheduled release workflow would otherwise publish this untested change). Re-land after testing by reverting this revert or re-applying the branch. Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Contributor
There was a problem hiding this comment.
Pull request overview
This PR reverts PR #513 (“fix(checkout): guard invalid carrier settings”) because the original fix was merged before it was fully tested, with the intent of keeping main in a releasable state until testing is completed and the fix can be re-landed safely.
Changes:
- Removes the regression tests that covered missing/malformed carrier settings scenarios introduced in #513.
- Reverts defensive type-guards in settings retrieval/validation that prevented crashes when stored carrier settings are not well-formed arrays.
- Restores the previous delivery-options behavior by removing carrier-settings sanitization and the early-bailout path in
DeliveryOptionsService.
Reviewed changes
Copilot reviewed 7 out of 7 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
| tests/Unit/Settings/Repository/AbstractSettingsRepositoryTest.php | Removes unit coverage for skipping malformed collection entries in settings. |
| tests/Unit/App/DeliveryOptions/Service/DeliveryOptionsServiceInvalidCarrierSettingsTest.php | Deletes regression suite for missing/invalid carrier settings behavior. |
| tests/Unit/App/DeliveryOptions/Service/DeliveryOptionsServiceCapabilitiesTest.php | Removes coverage for “malformed carrier entry” handling during carrier capability output. |
| tests/Unit/App/Context/Model/DeliveryOptionsConfigTest.php | Removes carrier-settings fixture setup used for delivery options config assertions. |
| src/Settings/Repository/AbstractPdkSettingsRepository.php | Reverts malformed-entry guards when building settings collections from storage. |
| src/Carrier/Service/CapabilitiesValidationService.php | Reverts array/type checks around enabled-carrier detection from settings. |
| src/App/DeliveryOptions/Service/DeliveryOptionsService.php | Reverts carrier-settings sanitization/early return that prevented checkout crashes on invalid settings. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
Comment on lines
138
to
142
| $category = $this->get($this->createSettingsKey($settingsId)) ?? []; | ||
|
|
||
| if (! is_array($category)) { | ||
| $category = []; | ||
| } | ||
|
|
||
| foreach (array_keys($category) as $key) { | ||
| $values = $this->get($this->createSettingsKey("$settingsId.$key")); | ||
|
|
||
| if (! is_array($values)) { | ||
| continue; | ||
| } | ||
| foreach ($category as $key => $item) { | ||
| $values = ['id' => $key] + $this->get($this->createSettingsKey("$settingsId.$key")); | ||
|
|
Comment on lines
134
to
141
| $carrierSettings = Settings::get(CarrierSettings::ID) ?? []; | ||
|
|
||
| if (! is_array($carrierSettings)) { | ||
| return []; | ||
| } | ||
|
|
||
| return array_keys( | ||
| array_filter( | ||
| $carrierSettings, | ||
| static function ($settings): bool { | ||
| return is_array($settings) | ||
| && ! empty($settings[CarrierSettings::DELIVERY_OPTIONS_ENABLED]); | ||
| return ! empty($settings[CarrierSettings::DELIVERY_OPTIONS_ENABLED]); | ||
| } |
Comment on lines
232
to
236
| $allCarriers = $this->carrierRepository->all(); | ||
| $carrierSettings = Settings::get(CarrierSettings::ID); | ||
| $shippingAddress = $cart->shippingMethod->shippingAddress; | ||
| $cc = $shippingAddress->cc ?? null; | ||
| $isBusiness = $shippingAddress->isBusiness; |
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #520 +/- ##
============================================
+ Coverage 94.31% 94.33% +0.01%
+ Complexity 2420 2414 -6
============================================
Files 352 352
Lines 7738 7726 -12
============================================
- Hits 7298 7288 -10
+ Misses 440 438 -2 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Contributor
Author
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Reverts #513 (squash commit 393ad70).
The change was merged prematurely — it still needs to be tested (see tester notes in the ticket). This temporary revert keeps
mainreleasable: the scheduled "Publish new version" workflow would otherwise ship the untested change in the next release (last run failed, next run would pick it up).Re-landing after testing: restore the original branch and either revert this revert or re-apply the commits on a fresh branch (the original commits remain in
main's history, so a plain re-merge will report "nothing to merge").