Skip to content

PAN-2529-Sample-Gorgias-Shipbob-in-Go - #19

Open
shanta3220 wants to merge 7 commits into
masterfrom
PAN-2529-Sample-Gorgias-Shipbob-in-Go
Open

PAN-2529-Sample-Gorgias-Shipbob-in-Go#19
shanta3220 wants to merge 7 commits into
masterfrom
PAN-2529-Sample-Gorgias-Shipbob-in-Go

Conversation

@shanta3220

@shanta3220 shanta3220 commented Sep 1, 2026

Copy link
Copy Markdown
Contributor

@shanta3220
shanta3220 force-pushed the PAN-2529-Sample-Gorgias-Shipbob-in-Go branch from 13b7054 to 25616b6 Compare September 4, 2026 21:27

@sarahtrefethen sarahtrefethen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My only true blocker here is the lack of support for a .env file, particularly given that the readme doesn't match the code.

But I would encourage you to also consider a signal handler context for the timeout watcher, a struct for webhooks, and simplifying the email parser -- I think these will make the code a lot nicer.

I also strongly suggest going through the comments and removing references to python, javascript, and other implementations. Someone reading this integration is probably only going to read this one, the others aren't relevant.

Comment on lines +37 to +42
**The run-limit deadline** is `time.AfterFunc`, not a signal handler. A `context.WithTimeout`
was considered and rejected: cancelling a context makes the *next* HTTP call return an
error, which looks like a failure — but the actual desired behavior on timeout is "stop
cleanly, flush the cursor, and succeed." `time.AfterFunc` schedules a callback on its own
goroutine without touching anything in flight, which is the right shape for "succeed early"
rather than "fail early":

@sarahtrefethen sarahtrefethen Sep 9, 2026

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

My robot disagrees with yours here:

Use a context.Context for the run deadline instead of a watchdog goroutine... the 
loop can check ctx.Err() between orders and return the cursor normally, 
which is exactly what the C# port does with its cancellation token. That one 
change removes the mutex around the cursor, the time.AfterFunc 
goroutine, the injected Exit and ArmWatchdog seams, and the stdout-capture
plus recover-from-panic scaffolding in the timeout test. It also lets requests be 
built with NewRequestWithContext, so an in-flight call is torn down at
the deadline. A Go reader expects context here, and it makes the Pandium 
point clearer: a run that stops itself early is still a success.

Comment thread SHIPBOB_TO_GORGIAS/go/webhook.go Outdated
// ShipmentID reads the shipment id off a webhook event. ShipBob names it "id" on
// the webhook body; older docs and some topics call it "shipment_id". Accept
// either.
func ShipmentID(event map[string]any) string {

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe add a Struct for webhook events? Would do away with deepGet and a lot of the work this file is doing with types


// emailRE mirrors the check the older integration used, so a recipient email
// found here is one Gorgias would actually accept.
var emailRE = regexp.MustCompile(`^([-!#-'*+/-9=?A-Z^-~]+(\.[-!#-'*+/-9=?A-Z^-~]+)*|"([\]!#-[^-~ \t]|(\\[\t -~]))+")@([-!#-'*+/-9=?A-Z^-~]+(\.[-!#-'*+/-9=?A-Z^-~]+)*|\[[\t -Z^-~]*])$`)

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

claude pointed me to go's standard library support for email (https://pkg.go.dev/net/mail) apparently this entire function could be replaced with a call to mail.ParseAddress and a check that the parsed address equals the input.

@shanta3220
shanta3220 force-pushed the PAN-2529-Sample-Gorgias-Shipbob-in-Go branch from 25a59bb to 3ab53c5 Compare September 10, 2026 13:28
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.

2 participants