Bulk import recognises a user's UUID with or without dashes, and names an unknown UUID
❌ This issue is not open for contribution. Visit Contributing guidelines to learn about the contributing process and how to find suitable issues.
Target branch: develop
Context
Part of #15792. Covers its dashed-UUID and unknown-UUID scope items.
Observed behavior
- A row whose
UUIDis an existing user's ID in dashed form (str(uuid.UUID(id))) is treated as an unknown UUID. With--delete, that user is then hard-deleted. The undashed form keeps them. - An unknown UUID is reported against the
PASSWORDcolumn, with the row's username where the UUID belongs.
Errors and logs
Row <unknown hex id>,bob,*,Bob,LEARNER,,,,,:
{'row': 1, 'username': 'bob', 'message': "Cannot update user with ID: 'bob' because no user with that database ID exists in this facility", 'field': 'PASSWORD', 'value': '*'}
Expected behavior
A row's UUID identifies its user in any form the UUID column's validator accepts.
User-facing consequences
- An admin who imports with "delete users not in the file" permanently loses every user whose ID is written with dashes.
- An admin who imports a CSV exported from another facility, with its
UUIDcolumn still filled in, sees every row reported as aPASSWORDerror (#7192).
Steps to reproduce
- In facility
F, create learnerbob. - Write a CSV with the header row and
<bob's id with dashes>,bob,*,Bob,LEARNER,,,,,. - Run
kolibri manage bulkimportusers <file> --facility <F's id> --delete. bobno longer exists.
Out of scope
- Crashes on malformed files and options: #13260.
- Other existing-user bugs: #15792.
Acceptance criteria
- [ ] A row whose
UUIDis an existing user's ID in dashed form updates that user, as the undashed form does. - [ ] With
--delete, that user is not deleted. - [ ] A row with an unknown UUID is reported with
'field': 'UUID'and a message containing that UUID. - [ ] The #15792 repro tests
test_dashed_uuid_matches_existing_user_with_deleteandtest_unknown_uuid_error_names_uuidpass.
References
build_users_objectsmatches the row's rawUUIDstring against stored IDs;get_deletedeletes every user not matched.valid_uuidaccepts any formuuid.UUIDparses._new_userbuilds the unknown-UUID error.
AI usage
Claude Code split #15792 into sub-issues and drafted this one from its scope and the code at 07e85c89ef.
Plan: A row's UUID matches its user in any form uuid.UUID parses, and an unknown UUID is reported against the UUID column, naming the UUID.
- [ ] Match an existing user's UUID in any valid form
- [ ] Report an unknown UUID against the
UUIDcolumn - [ ] Self-review the produced code
Assumptions — the issue did not settle these; say so if one is wrong.
- The error's
valueand message show the UUID as written in the CSV; if hex is wanted, format withvalues["uuid"]instead. - Only the two named repro tests land here, in
ImportTestCase; the rest of #15792's repro class lands with #13260 and #15782.
Written by rtibblesbot, an LLM-based coding agent.