fix(import): gracefully handle orphaned client references in Toggl importer#1087
fix(import): gracefully handle orphaned client references in Toggl importer#1087DavidLambauer wants to merge 1 commit into
Conversation
|
I just tried to reproduce this with toggl exports but when could not reproduce an export where the client id is still in the projects.json but not in clients.json. After deleting the client, the reference was gone in the projects.json export too, which is imo how it should be. Did you combine two exports that happened at different times (before and after deleting the client) to get the Error? |
|
I don't know tbh. I just followed the modal that told me how to export data from our Toggl account. We've been using Toggl for years and are now evaluating SolidTime. Could it be that our account's data got messed up? I obviously told claude to investigate the issue and he came up with the patch which made me import our data successfully. So I thought I feed that patch back to you. |
|
If it helps, I can anonymize our Toggl export so you can test it with our data? |
|
@DavidLambauer Please try it again with a new export and do not modify the export before importing. If this still happens then please send us an anonymized export. If you don't want to send it here you can also send it via email. |
Summary
When importing a Toggl data export, the importer throws an unhandled
Exception("Client does not exist")if a project references aclient_idthat isn't present inclients.json. This happens when a client was deleted in Toggl but the project still carries the old reference. The exception gets swallowed into a generic "Unknown error" response, giving the user no actionable feedback.The fix skips the missing client reference (leaving the project with no client) and logs a warning instead of aborting the entire import.
What changed
TogglDataImporter.php: replacedthrow new Exception('Client does not exist')with aLog::warning()when a project'sclient_idhas no matching entry in the imported clients. The project is still imported, just without a client assigned.How I tested it
Reproduced by running a Toggl export where one project referenced a since-deleted client. Before this change: full import fails with "Unknown error". After: import completes, the orphaned project is imported without a client, warning appears in the log.
Notes
The deleted client can't be recovered from the export, so silently dropping the reference is the most reasonable fallback. If a stricter behavior is preferred, the warning message makes it easy to surface this in the UI later.