kolibri icon indicating copy to clipboard operation
kolibri copied to clipboard

Bulk import recognises a user's UUID with or without dashes, and names an unknown UUID

Open rtibblesbot opened this issue 3 weeks ago • 1 comments

❌ 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 UUID is 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 PASSWORD column, 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 UUID column still filled in, sees every row reported as a PASSWORD error (#7192).

Steps to reproduce

  1. In facility F, create learner bob.
  2. Write a CSV with the header row and <bob's id with dashes>,bob,*,Bob,LEARNER,,,,,.
  3. Run kolibri manage bulkimportusers <file> --facility <F's id> --delete.
  4. bob no longer exists.

Out of scope

  • Crashes on malformed files and options: #13260.
  • Other existing-user bugs: #15792.

Acceptance criteria

  • [ ] A row whose UUID is 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_delete and test_unknown_uuid_error_names_uuid pass.

References

AI usage

Claude Code split #15792 into sub-issues and drafted this one from its scope and the code at 07e85c89ef.

rtibblesbot avatar Nov 08 '26 08:11 rtibblesbot

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 UUID column
  • [ ] Self-review the produced code

Assumptions — the issue did not settle these; say so if one is wrong.

  • The error's value and message show the UUID as written in the CSV; if hex is wanted, format with values["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.

rtibblesbot avatar Nov 08 '26 08:11 rtibblesbot