Skip to content

Fix: guard against None elements in BatchCreateResponseFormatter#70

Open
ZLeventer wants to merge 1 commit intolinkedin-developers:mainfrom
ZLeventer:fix/default-empty-list
Open

Fix: guard against None elements in BatchCreateResponseFormatter#70
ZLeventer wants to merge 1 commit intolinkedin-developers:mainfrom
ZLeventer:fix/default-empty-list

Conversation

@ZLeventer
Copy link
Copy Markdown

Summary

  • Fixes default value should be empty list to iterate on it #62BatchCreateResponseFormatter.format_response() crashes with TypeError when elements key is absent from the JSON response
  • json_data.get("elements", None) returns None, which is then iterated in a list comprehension
  • Added a conditional so batch_create_results defaults to [] when elements is None
  • Matches the existing pattern used by BatchFinderResponseFormatter in the same file

Test plan

  • Call a batch create endpoint that returns a response without an elements key
  • Verify no TypeError is raised and an empty list is returned for batch_create_results
  • Verify normal responses with elements present are unchanged

…g from batch create response

When the JSON response lacks an "elements" key, json_data.get() returns
None, which cannot be iterated. Default to an empty list instead, matching
the pattern already used by BatchFinderResponseFormatter.

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
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.

default value should be empty list to iterate on it

1 participant