Repository navigation
fix(tracking): generate tracking numbers from letters and digits only - #416
Merged
roncodes merged 3 commits intoOct 23, 2026
Merged
Conversation
Tracking numbers are generated with the first three characters of the company name as their prefix, so a company named "Al Noor" issues numbers like "AL 7796486490AE". The lookup pattern added in #352 has no space in its character class, so the public tracking page and fleet-ops/lookup now answer "not found" for those numbers. Allow a space only when it sits between two allowed characters. Leading, trailing and repeated spaces, tabs, newlines, quotes and other symbols are still refused, and the 100 character limit is unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
…refix generateTrackingNumber() takes the first three characters of the company name as they are, so names such as "Al Noor" or "A&B Logistics" produce numbers containing a space or "&", and names in non-Latin scripts produce partial multibyte characters. Keep only A-Z and 0-9 from those three characters and fall back to FLB when nothing is left. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
Two parts of a generated number could carry a space or punctuation: - The prefix took the first three characters of the company name, then dropped what was not a letter or digit, so "Al Noor Transport" gave AL and "A&B Logistics" gave AB. It now skips those characters first and takes the first three letters or digits (ALN, ABL), falling back to FLB. - The suffix appended the region as given. The region falls back to the pickup's province or district when it has no country, and POST /v1/tracking-numbers accepts any string, so a pickup in "New York" issued ...NEW YORK. It now keeps only letters and digits, falling back to SG. Numbers already issued keep working through the lookup change in this PR.
roncodes
added a commit
that referenced
this pull request
Oct 23, 2026
This was referenced Oct 23, 2026
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## release/v0.6.75 #416 +/- ##
===================================================
Coverage 100.00% 100.00%
- Complexity 13596 13601 +5
===================================================
Files 634 634
Lines 49342 49349 +7
===================================================
+ Hits 49342 49349 +7
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
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.
Root-cause fix for the tracking numbers with spaces from #413. #413 makes lookups accept the numbers already issued. This PR stops new ones from containing anything but letters and digits.
Stacked on #413. This branch contains #413's two commits. Merge #413 into
release/v0.6.75first; after that, this PR's diff is only the last commit.Why
TrackingNumber::generateTrackingNumber()builds a number from a company prefix, random digits and a region suffix. Both ends could still contain spaces or punctuation:ALand "A&B Logistics" givesAB. That's safe, but shorter than intended.strtoupper($region)). The region falls back to the pickup's province or district when the pickup has no country (Payload::getPickupRegion(),ResolvesOrderServiceStops), andPOST /v1/tracking-numbersaccepts any string. So a pickup in "New York" issued numbers ending inNEW YORK.Changes
trackingNumberPrefix()removes anything that isn't a letter or digit first, then takes three characters:ALN,ABL,OBR. It falls back toFLB, which is also what names in non-Latin scripts get.trackingNumberSuffix()keeps the region's letters and digits (NEWYORK) and falls back toSG.trackingNumberCharacters()helper (ASCIIA-Z0-9, upper-cased).Numbers already issued are not renamed, because that would break printed labels and barcodes. They keep resolving through #413's lookup change.
Tests
TrackingNumberTest:/^[A-Z0-9]+$/for awkward regions.TrackingNumberTest,ModelLookupFallbackSeamsTest,TrackingResolverTest,ObserverContractsTest,QuerySeamsTestandOrderControllerContractsTest(73 tests). php-cs-fixer is clean.