Repository navigation
Conversation
_convert_dict_keys appended a copy of the whole list for every element of a list that does not hold dicts, so a value like schemas: ["a", "b"] became [["a", "b"], ["a", "b"]]. Append a copy of each element instead.
WilliamBergamin
left a comment
There was a problem hiding this comment.
Thanks for tracking this down!
One small request inline: a response-level assertion so the user-facing symptom is covered too. Happy to approve once CI runs green 🚀
| result_dict[new_key].append(new_element) | ||
| else: | ||
| result_dict[new_key].append(_create_copy(original_value)) | ||
| result_dict[new_key].append(_create_copy(element)) |
There was a problem hiding this comment.
praise: Nice catch, this is the right fix. Copying element instead of original_value keeps the list flat and leaves the list-of-dicts branch untouched.
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #1973 +/- ##
==========================================
+ Coverage 84.73% 84.76% +0.02%
==========================================
Files 118 118
Lines 14129 14129
==========================================
+ Hits 11972 11976 +4
+ Misses 2157 2153 -4 ☔ View full report in Codecov by Harness. |
|
Added the |
| ) | ||
| user = response.users[0] | ||
| self.assertEqual(user.schemas, ["urn:scim:schemas:core:1.0"]) | ||
| self.assertEqual(response.snake_cased_body["schemas"], ["urn:scim:schemas:core:1.0"]) |
There was a problem hiding this comment.
praise: Good call asserting on snake_cased_body["schemas"] here. It's the one that fails on main, and it's the same dict ReadUserResponse.user is built from, so the user-facing bug is pinned. 🙌
|
Updated the branch from |
|
CI is green across every Python version, with lint, typecheck, and codecov passing too. ✅ @WilliamBergamin the response-level assertion you asked for is in, so this is ready for a re-review when you have a moment. 🙏 |
Summary
_convert_dict_keys(used bySCIMResponse.snake_cased_body) handles a list whose items are not dicts by appending_create_copy(original_value)for every element, so it copies the whole list once per element instead of copying the element. For a response like{"schemas": ["urn:scim:schemas:core:1.0"]},schemasbecomes[["urn:scim:schemas:core:1.0"]], and a list with two items becomes two copies of itself. As a resultReadUserResponse.user.schemas(andgroup.schemason the group responses) is a nested list, and passing that user back toupdate_usersends"schemas": [["urn:scim:schemas:core:1.0"]].The fix appends a copy of
elementinstead. Lists of dicts go through the other branch and are unchanged.Testing
Added
test_snake_cased_list_of_plain_valuestotests/slack_sdk/scim/test_internals.py. It fails before the change (the result is[[...], [...]]) and passes after. The SCIM test suites (sync and async),ruff format --checkandruff checkwere run locally.Category
/docs(Documents)/tutorial(PythOnBoardingBot tutorial)tests/integration_tests(Automated tests for this library)Requirements
python3 -m venv .venv && source .venv/bin/activate && ./scripts/run_validation.shafter making the changes.