Skip to content

fix(import): gracefully handle orphaned client references in Toggl importer#1087

Open
DavidLambauer wants to merge 1 commit into
solidtime-io:mainfrom
DavidLambauer:fix/toggl-importer-orphaned-client
Open

fix(import): gracefully handle orphaned client references in Toggl importer#1087
DavidLambauer wants to merge 1 commit into
solidtime-io:mainfrom
DavidLambauer:fix/toggl-importer-orphaned-client

Conversation

@DavidLambauer
Copy link
Copy Markdown

Summary

When importing a Toggl data export, the importer throws an unhandled Exception("Client does not exist") if a project references a client_id that isn't present in clients.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: replaced throw new Exception('Client does not exist') with a Log::warning() when a project's client_id has 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.

@CLAassistant
Copy link
Copy Markdown

CLAassistant commented May 22, 2026

CLA assistant check
All committers have signed the CLA.

@Onatcer
Copy link
Copy Markdown
Contributor

Onatcer commented May 22, 2026

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?

@DavidLambauer
Copy link
Copy Markdown
Author

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.

@DavidLambauer
Copy link
Copy Markdown
Author

If it helps, I can anonymize our Toggl export so you can test it with our data?

@korridor
Copy link
Copy Markdown
Contributor

@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.

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.

4 participants