Repository navigation
Fix silent API failures, regional OAuth, pagination, and config permissions - #4
Merged
Merged
Conversation
Amazon's v3/v4 batch endpoints (create/update/delete) return 207 with per-item success and error arrays in the body. The client treated any OK status as success, so keyword bid updates, campaign creates, and archives printed a success message even when Amazon rejected the item. makeRequest now scans OK response bodies for a non-empty error array and throws with the errorType and errorValue for each rejected item.
The consent page and token service were hardcoded to the North America hosts, so EU and FE advertisers could not complete auth login. Region was also only asked for after the browser flow, too late to pick the right consent host. Add src/lwa.ts with the per-region consent and token URLs from Amazon's authorization-grants docs, ask for region (and sandbox) before opening the browser, and refresh access tokens against the regional token host. Region input is now validated; an unknown value fails instead of silently falling back to NA.
getCampaignPerformance filtered the report to the requested campaign but fell back to the unfiltered report when nothing matched, so a typo'd or inactive campaign ID silently showed every campaign in the account. Return the filtered rows as-is; the command already prints "No performance data found." for an empty result.
The v3/v4 list endpoints page their results and return a nextToken when more remain. The client only ever requested the first page, so accounts with more entities than one page holds got silently truncated lists. Add a listAll helper that re-posts the same filters with each nextToken and merges the pages under the entity key, so --json output keeps the same shape as a single-page response.
config.json stores the client secret and refresh token but was written with the default umask, typically world-readable. Create the directory 0700 and the file 0600, and chmod both on every save so an existing file left over from an older version is tightened as well.
- Remove axios; nothing imports it, the client uses fetch. - Point the clean script at build/, the actual tsc outDir, not dist/. - Ignore .claude/worktrees/ so session worktrees never get committed. - Fix .env.example: drop AMAZON_ADS_API_ENDPOINT, which the CLI never reads, and document REGION, SANDBOX, and PROFILE_ID, which it does.
2 of 3 tasks
2 of 3 tasks
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
Fixes from a review pass over the CLI. Each is its own commit with tests written first.
success/errorarrays. The client treated any OK status as success, sokeywords update-bid,campaigns create, andcampaigns archiveprinted success even when Amazon rejected the item. The client now throws with each item'serrorTypeanderrorValue.auth login. Newsrc/lwa.tsholds the per-region hosts from Amazon's authorization-grants docs. Region (and sandbox) are now asked before the browser opens. Unknown region values fail instead of silently using NA.campaigns performance --campaign Xfell back to every campaign's rows when X had no data. Returns an empty result now.nextTokenand merge pages.--jsonshape is unchanged.config.jsonholds the client secret and refresh token. Directory is now 0700, file 0600, tightened on every save.axios, fixcleanscript (build/notdist/), ignore.claude/worktrees/, fix.env.exampleto list the variables the CLI actually reads.Test plan
npm test— 49 tests pass (18 new, including the first tests forAmazonAdsClient)npm run buildcleanamazonads auth loginend to end against a real EU or FE account (no test account available here)