Skip to content

Fix KeyError in promise_batch_imports.py script#12835

Open
jimchamp wants to merge 2 commits into
masterfrom
promise-item-key-error-fixup
Open

Fix KeyError in promise_batch_imports.py script#12835
jimchamp wants to merge 2 commits into
masterfrom
promise-item-key-error-fixup

Conversation

@jimchamp
Copy link
Copy Markdown
Collaborator

@jimchamp jimchamp commented Jun 1, 2026

The promise item cron job is sometimes failing with a KeyError when attempting to access the sku in a promise item record. This occurs within the map_book_to_olbook function.

This branch updates the code to use the get method to access this data. If a sku is not found, the promise item's json is logged, and None is returned by map_book_to_olbook.

Technical

Testing

Screenshot

Stakeholders

Copilot AI review requested due to automatic review settings June 1, 2026 21:03
Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Fixes a KeyError in the promise_batch_imports.py cron job by switching from bracket indexing to .get() lookups when extracting the SKU fields from a promise item record, and gracefully skipping records that lack any SKU.

Changes:

  • Use dict.get() for BookSKUB, BookSKU, and BookBarcode in map_book_to_olbook, logging and returning None when no SKU is found.
  • Filter out None results from the generator passed into batch_import using an assignment expression.

Comment thread scripts/promise_batch_imports.py
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