Skip to content

feat(common): Client with conditional err handling#2247

Merged
Cobalt0s merged 2 commits into
mainfrom
cobalt0s/client-custom-err-conditional
Nov 5, 2025
Merged

feat(common): Client with conditional err handling#2247
Cobalt0s merged 2 commits into
mainfrom
cobalt0s/client-custom-err-conditional

Conversation

@Cobalt0s
Copy link
Copy Markdown
Contributor

@Cobalt0s Cobalt0s commented Oct 31, 2025

Current behaviour

When response status code is out of 2xx range we invoke ErrorHandler and operation returns golang error.

res.StatusCode < 200 || res.StatusCode > 299

Addition

The condition of what should be treated as "critical error" is for the connector implementation.
The change only enhances and fallbacks for current behaviour if no custom ShouldHandleError callback is provided.

For example:
Salesforce composite API may return 400 Bad Request with schema which we should parse in order to form BatchWriteResult. It is still a "happy path" from Ampersand point of view, because we populate data structure with errors, set status failure or partial failure, etc.

If provider treats it as "error" doesn't mean we do.

Note: there is ResponseHandler which alters http.Response but I prefer to keep it immutable, especially for the case I described.

Copy link
Copy Markdown
Contributor Author

Cobalt0s commented Oct 31, 2025

@Cobalt0s Cobalt0s self-assigned this Oct 31, 2025
@Cobalt0s Cobalt0s marked this pull request as ready for review October 31, 2025 03:03
@Cobalt0s Cobalt0s requested a review from laurenzlong October 31, 2025 03:03
@Cobalt0s Cobalt0s force-pushed the cobalt0s/client-custom-err-conditional branch from 2d13aed to 8a46341 Compare November 3, 2025 21:57
@Cobalt0s Cobalt0s force-pushed the cobalt0s/batch-write-utils branch from 2b85a05 to 3b3ab66 Compare November 3, 2025 21:57
@Cobalt0s Cobalt0s force-pushed the cobalt0s/client-custom-err-conditional branch from 8a46341 to 1863886 Compare November 4, 2025 17:33
@Cobalt0s Cobalt0s force-pushed the cobalt0s/batch-write-utils branch from 3b3ab66 to 259d000 Compare November 4, 2025 17:33
@Cobalt0s Cobalt0s force-pushed the cobalt0s/client-custom-err-conditional branch from 1863886 to 420d747 Compare November 4, 2025 20:36
@Cobalt0s Cobalt0s force-pushed the cobalt0s/batch-write-utils branch from 259d000 to 01207eb Compare November 4, 2025 20:36
@Cobalt0s Cobalt0s requested a review from anushat05 November 4, 2025 22:53
@Cobalt0s Cobalt0s changed the base branch from cobalt0s/batch-write-utils to graphite-base/2247 November 5, 2025 00:48
@Cobalt0s Cobalt0s force-pushed the cobalt0s/client-custom-err-conditional branch from 420d747 to aec7c2b Compare November 5, 2025 00:51
@Cobalt0s Cobalt0s changed the base branch from graphite-base/2247 to cobalt0s/batch-write-utils November 5, 2025 00:51
Base automatically changed from cobalt0s/batch-write-utils to main November 5, 2025 00:55
@Cobalt0s Cobalt0s merged commit 094b323 into main Nov 5, 2025
8 of 9 checks passed
@Cobalt0s Cobalt0s deleted the cobalt0s/client-custom-err-conditional branch November 5, 2025 00:55
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