Skip to content

fix(fleetops): decode the QR image instead of asking the API for the uuid - #37

Merged
roncodes merged 1 commit into
mainfrom
fix/decode-qr-in-script
Aug 12, 2026
Merged

fix(fleetops): decode the QR image instead of asking the API for the uuid#37
roncodes merged 1 commit into
mainfrom
fix/decode-qr-in-script

Conversation

@roncodes

Copy link
Copy Markdown
Member

The two QR requests need the value a scanner reads — the tracking number's owner uuid, which is the one documented place the API takes a uuid rather than a public_id. Neither had a source: Decode Tracking Number QR sent the literal {{qr_code}} and Capture QR Code for Order sent an empty string.

Create a Tracking Number already returns qr_code, a base64 PNG generated from that uuid, and it is public on the TrackingNumber resource (unlike Order and Entity, where it is isInternalRequest()-gated). The after-response script now decodes it with jsqr + fast-png and sets {{qr_code}}.

This reproduces what a scanning device actually does, which is the right thing for the collection to demonstrate — and avoids exposing the raw uuid on the API, which is not what that endpoint is for.

Details worth noting

  • One value serves both requests. captureQrScan resolves its subject as the order itself when no type is sent, and the tracking number is owned by {{order_id}} — so the decoded uuid matches $subject->uuid.
  • The decode is guarded. If the runtime cannot resolve the npm packages, the catch logs and the run continues; the two QR requests then fail visibly on their own rather than an unhandled script error taking the whole collection down.
  • The script also asserts the QR is decodable, so a tracking number that stopped carrying a readable code would be caught rather than silently skipped.

Requires Capture QR Code for Order to run after the tracking number exists — ordering change in fleetbase/fleetbase.

🤖 Generated with Claude Code

…uuid

The two QR requests need the value a scanner reads, which is the tracking
number's owner uuid — the one documented place the API takes a uuid rather than a
public_id. Neither had a source, so Decode Tracking Number QR sent the literal
{{qr_code}} and Capture QR Code for Order sent an empty string.

Create a Tracking Number already returns `qr_code`, a base64 PNG generated from
that uuid, and it is public on the TrackingNumber resource. The after-response
script now decodes it with jsqr and fast-png and sets {{qr_code}} — reproducing
what a scanning device does, rather than having the API expose the raw uuid.

The decode is wrapped: if the runtime cannot resolve the packages the rest of the
run continues and the two QR requests fail visibly on their own, rather than an
unhandled script error taking the collection down.

Capture QR Code for Order resolves its subject as the order itself when no `type`
is sent, and the tracking number is owned by {{order_id}} — so one decoded value
serves both requests.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@roncodes
roncodes merged commit 9ebf270 into main Aug 12, 2026
1 check passed
@roncodes
roncodes deleted the fix/decode-qr-in-script branch August 12, 2026 05:58
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.

1 participant