Repository navigation
fix: send the parameters these endpoints actually require, and stop building JSON by hand - #11
Merged
Conversation
…uilding JSON by hand
Audited the S3/SFTP file jobs and the Inbox Placement Tester against the
documented 74 operations and the live API. Several calls could not succeed as
the SDK built them, and the Tester built its request bodies in a way that a
quote in a caller's string could break.
Memory safety first:
- The Tester's JSON bodies were concatenated into a fixed 1024-byte buffer with
no escaping, so a quote or a backslash in `name`, `senderEmail` or
`webhookUrl` closed the string early and injected whatever followed, and
anything longer than the buffer was silently truncated mid-field. Every value
is escaped now and the bodies grow to fit.
- `send_file` dereferenced `SendFileOptions.return_url` without a NULL check on
the live request path, although the same value is checked where the request
is noted. A caller that zeroed the struct rather than calling
`new_send_file_options` crashed. Guarded.
Parameters:
- `validate_s3_file` and `score_s3_file` now require `return_url`, as the other
six jobs already did: POST /validateS3file without it answers 400 "Provided
return URL is not permitted: None". `ScoreS3FileOptions` had no `return_url`
field at all, so that job could never succeed. Both now go through the same
helper as the other jobs, which is also why `validate_s3_file` stops sending
`remove_duplicate` and `allow_phase_2`: the endpoint documents
`remove_duplicates`, and `allow_phase_2` belongs to the multipart bulk
`send_file`.
- `export_s3_file` rejected a missing `export_bucket` as an empty parameter
although the docs make it optional, and its SFTP twin treats it as optional.
It is optional here too now.
- `send_email_finder_file` enforces the documented "first_name_column or
full_name_column": without one the endpoint has no name to search for.
- `send_list_evaluator_file` built its URL from `bulk_api_base_url` while the
result call used `list_evaluator_base_url`, so
`zero_bounce_set_list_evaluator_base_url` split the two halves of the same
feature across different hosts. It honours the override now.
- `list_inbox_placement_tests` sent `pageSize`, which the API accepts and then
silently ignores, so a caller asking for a page size quietly got the default
page. It sends `page_size`, bounded to 1-100, and gained the documented
`createdAfter` / `createdBefore` filters.
- `create_inbox_placement_test` gained the unsupported `providerIds`, `seedIds`
and `providers[{id, maxSeeds}]`, and enforces name <= 64, testType 1|2|3 and
senderEmail when testType is 1.
Also: the regional-host warning told users to call
`zero_bounce_set_bulk_api_base_url`, which did not exist anywhere in the
codebase and left the three bulk URLs hardcoded to production. Added it along
with the root and scoring setters. Corrected the header comment claiming the
Tester's key goes on the query string; the code has always used
`Authorization: Bearer`, and the comment was telling readers to leak a key.
Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
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.
Audited the S3/SFTP file jobs and the Inbox Placement Tester against the documented operations and the live API. Several calls could not succeed as the SDK built them, and the Tester built its request bodies in a way a quote in a caller's string could break.
Memory safety
name,senderEmailorwebhookUrlclosed the string early and injected whatever followed, and anything longer than the buffer was silently truncated mid-field. Every value is escaped now and the bodies grow to fit (set_inbox_placement_webhookincluded).send_filedereferencedSendFileOptions.return_urlwithout a NULL check on the live request path, although the same value is checked where the request is noted. A caller that zeroed the struct instead of callingnew_send_file_optionscrashed.Parameters
validate_s3_filereturn_urlsent only when non-empty, never required; sent the non-specremove_duplicateandallow_phase_2return_urlrequired; routed through the same helper as the other jobsscore_s3_fileScoreS3FileOptionshad noreturn_urlfield, so the job could never succeedreturn_urlfield added and requiredexport_s3_fileexport_bucketas an empty parametersend_email_finder_filefirst_name_column/full_name_columnrequiredsend_list_evaluator_filebulk_api_base_url, ignoringlist_evaluator_base_urlcreate_inbox_placement_testproviderIds,seedIdsorproviders[{id, maxSeeds}]; no limitsname≤ 64,testType1|2|3,senderEmailrequired whentestTypeis 1list_inbox_placement_testspageSize, which the API silently ignores; no date filterspage_size(1–100) and the documentedcreatedAfter/createdBeforeLIVE-verified:
POST /validateS3filewithout areturn_urlanswers 400{"error_message":"Provided return URL is not permitted: None"}, andpage_sizeis honoured wherepageSizeis silently ignored.Also
zero_bounce_set_bulk_api_base_url,zero_bounce_set_bulk_api_root_urlandzero_bounce_set_bulk_api_scoring_base_url. The regional-host warning inzb_check_request_urlalready told users to call the first one, but it did not exist anywhere in the codebase and the three bulk URLs were hardcoded to production.Authorization: Bearer, and the comment was telling readers to leak a key — plus two comments callingvalidate_sftp_file'sfile_nameoptional where the code requires it.Compatibility
ScoreS3FileOptionsgains a field andvalidate_s3_file/score_s3_filenow reject a call withoutreturn_url, which the API rejected anyway.ValidateS3FileOptions.remove_duplicate,allow_phase_2andallow_phase_2_is_setare kept so existing code still compiles, and are documented as no longer sent.Tests
Offline Unity tests with mocked HTTP for every changed call: method, host and path, the full parameter set, where the key travels, and the error bodies (
"success": falseon 200, an HTML block page, an empty body, adetailerror). No key is written anywhere.cmake --build buildis clean, a-Wall -Wextra -Wshadowbuild adds no warning that was not already there, the opt-in live suite still compiles, and the suite also passes under ASan + UBSan.🤖 Generated with Claude Code