fix: Check the error from constructing the event poll request - #67
Merged
Conversation
eventLoop discarded the error from http.NewRequest and set a header on the returned request immediately. On a construction failure that request is nil, so the daemon panicked on a nil pointer dereference instead of reporting the problem. The loop returns the error rather than logging it and polling again. pollURI is computed once from SALESFORCE_URL before the loop starts, so a URL that url.Parse rejects fails identically on every iteration; retrying would spin forever with no way to make progress, and would hide an operator misconfiguration behind a log line. featureLoop already returns from the identical call, so this also makes the two loops agree. err is reassigned a few lines down by the requestWithOauth call, which is in the same block, so the new check reads the same variable rather than shadowing it and nothing goes unused. The test drives eventLoop with a SALESFORCE_URL holding a control character, which is what makes url.Parse fail. It recovers a panic in the loop's goroutine so the old behavior fails one test instead of killing the test binary.
tanderson-ld
approved these changes
Aug 31, 2026
kinyoklion
approved these changes
Aug 31, 2026
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.
Summary
eventLoopdiscarded the error fromhttp.NewRequestand set a header on thereturned request immediately. On a construction failure that request is nil, so the
daemon panicked on a nil pointer dereference instead of reporting the problem.
featureLoopalready checks the identical call, so the two loops now agree.The loop returns the error rather than logging it and polling again.
pollURIiscomputed once from
SALESFORCE_URLbefore the loop starts, so a URL thaturl.Parserejects fails identically on every iteration -- retrying would spinforever with no way to make progress, and would bury an operator misconfiguration
in a log line.
The new test drives
eventLoopwith aSALESFORCE_URLholding a controlcharacter, which is what makes
url.Parsefail. It recovers a panic inside theloop goroutine, so the previous behavior surfaces as one test failure rather than
killing the test binary. Verified to bite: with the check removed the test fails
with
invalid memory address or nil pointer dereference.Note
Overview
eventLoopnow checks the error fromhttp.NewRequestbefore setting headers on the poll request, matchingfeatureLoop. A badSALESFORCE_URL(e.g. oneurl.Parserejects) used to yield a nil request and crash the daemon on header setup; the loop now returns that error instead of retrying, becausepollURIis fixed for the process lifetime so retries would only spin.A new test drives
eventLoopwith an invalid Salesforce base URL, asserts no panic, expects the same construction error ashttp.NewRequest, and times out if the loop keeps polling.Reviewed by Cursor Bugbot for commit 227ea39. Bugbot is set up for automated code reviews on this repo. Configure here.