Skip to content

fix(warehouse): correct label extension, surface print errors, revert…#94

Open
thesleepyniko wants to merge 1 commit into
mainfrom
claude/fix-label-pdf-corruption-CE3y7
Open

fix(warehouse): correct label extension, surface print errors, revert…#94
thesleepyniko wants to merge 1 commit into
mainfrom
claude/fix-label-pdf-corruption-CE3y7

Conversation

@thesleepyniko
Copy link
Copy Markdown
Collaborator

… status on carrier failure

  • Use .png extension for Chit Chats PNG labels (was hardcoded .pdf, breaking PDF readers)
  • Wrap QZ Tray qz.print() calls in try/catch and surface failures via labelErrors[orderId]
  • Revert warehouseOrder.status back to APPROVED if carrier throws after the SHIPPED claim, so retries don't hit "already shipped" 409

… status on carrier failure

- Use .png extension for Chit Chats PNG labels (was hardcoded .pdf, breaking PDF readers)
- Wrap QZ Tray qz.print() calls in try/catch and surface failures via labelErrors[orderId]
- Revert warehouseOrder.status back to APPROVED if carrier throws after the SHIPPED claim,
  so retries don't hit "already shipped" 409

Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>
@thesleepyniko thesleepyniko requested a review from Copilot May 19, 2026 22:28
@vercel
Copy link
Copy Markdown

vercel Bot commented May 19, 2026

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Actions Updated (UTC)
resolution Ready Ready Preview, Comment May 19, 2026 10:28pm

Request Review

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR improves warehouse label/packing-slip handling by fixing Chit Chats label download filenames, surfacing QZ Tray print failures in the UI, and making /api/fulfillment/get-label resilient to carrier failures by rolling back an order’s status when shipment creation fails after the “SHIPPED” claim.

Changes:

  • Generate label download filenames with a .png extension when the label is a PNG data URL.
  • Wrap QZ Tray qz.print() calls in try/catch and report failures via labelErrors[orderId].
  • Add a try/catch around post-claim shipment creation so failures revert warehouseOrder.status from SHIPPED back to APPROVED to allow retries.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
resolution-frontend/src/routes/app/warehouse/fulfillment/+page.svelte Adds label filename inference for PNG/PDF and surfaces QZ print errors per order.
resolution-frontend/src/routes/api/fulfillment/get-label/+server.ts Rolls back status to APPROVED on post-claim carrier failures to avoid “already shipped” retry dead-ends.
Comments suppressed due to low confidence (2)

resolution-frontend/src/routes/app/warehouse/fulfillment/+page.svelte:112

  • printAll now records print failures in labelErrors, but it never clears a previous error when the user retries printing. This can leave a stale error displayed even after a subsequent successful print. Consider resetting labelErrors[orderId] at the start of printAll (and/or clearing it after successful label + slip printing).
	async function printAll(orderId: string, result: { labelUrl: string | null; packingSlipBase64: string }) {
		if (!qz || qzStatus !== 'connected') return;
		const settings = getQZSettings();
		if (!settings.printer) { alert('No printer selected. Go to Settings to configure.'); return; }
		const config = () => qz.configs.create(settings.printer, {

resolution-frontend/src/routes/api/fulfillment/get-label/+server.ts:160

  • The try { block introduced here isn't indented, which makes it harder to visually see what is covered by the rollback catch. Re-indent the code inside the try to match the surrounding style.
	try {
	// Total weight always comes from items. Dimensions come from the packaging
	// record chosen at estimate time so the carrier request matches the quote.
	// Fall back to item-derived dims for legacy orders without packaging info.
	const MAX_HEIGHT_IN = 48;

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines +133 to +137
try {
await qz.print(config(), [{ type: 'html', format: 'plain', data: html }]);
} catch (e: any) {
labelErrors[orderId] = `Packing slip print failed: ${e?.message || e}`;
}
Comment on lines +370 to +375
await db.update(warehouseOrder)
.set({ status: 'APPROVED', updatedAt: new Date() })
.where(and(
eq(warehouseOrder.id, orderId),
eq(warehouseOrder.status, 'SHIPPED')
));
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.

3 participants