Skip to content

Conversation

Copy link

Copilot AI commented Feb 9, 2026

json_should_be_valid() was annotated to return dict but returned whatever json.loads() yielded. When the model returned JSON arrays or primitives, json_should_have_keys() raised AttributeError instead of a clear assertion failure.

Changes

  • Add isinstance(data, dict) check in json_should_be_valid() after parsing JSON
  • Raise AssertionError with clear message when JSON is not an object: "Expected JSON object (dict), but got list"
  • Document assumption in json_should_have_keys() that upstream validates dict type

Example

# Before: AttributeError: 'list' object has no attribute 'keys'
lib._last_response = '[1, 2, 3]'
lib.json_should_have_keys("name", "age")  # Crashes

# After: AssertionError: Expected JSON object (dict), but got list.
# Value: [1, 2, 3]

💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.

Copilot AI and others added 3 commits February 9, 2026 17:55
…eError

Co-authored-by: Michspirit99 <11279621+Michspirit99@users.noreply.github.com>
Co-authored-by: Michspirit99 <11279621+Michspirit99@users.noreply.github.com>
Co-authored-by: Michspirit99 <11279621+Michspirit99@users.noreply.github.com>
Copilot AI changed the title [WIP] Update pytest AI validation and Robot Framework BDD samples Fix type safety in Robot Framework JSON validation methods Feb 9, 2026
Copilot AI requested a review from Michspirit99 February 9, 2026 17:58
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