AxaliaN / toggl-jira

A sync tool to log time logged in Toggl to Jira issues
BSD 3-Clause "New" or "Revised" License
2 stars 4 forks source link

Crashes on single-word Toggl logs #13

Open wizonesolutions opened 5 years ago

wizonesolutions commented 5 years ago

Describe the bug Toggl entries like ABCD-1234 will cause the script to crash because it expects a description on the right-hand side of the split string, but this causes the right-hand side to be NULL.

Application exception:
======================================================================
The application has thrown an exception!
======================================================================

TypeError:
explode() expects parameter 2 to be string, null given
0
/usr/src/toggl-jira/module/TogglJira/src/Service/SyncService.php
212
#0 /usr/src/toggl-jira/module/TogglJira/src/Service/SyncService.php(212): explode(' ', NULL)
#1 /usr/src/toggl-jira/module/TogglJira/src/Service/SyncService.php(179): TogglJira\Service\SyncService->parseTimeEntry(Array)
#2 /usr/src/toggl-jira/module/TogglJira/src/Service/SyncService.php(126): TogglJira\Service\SyncService->parseTimeEntries(Array)
#3 /usr/src/toggl-jira/module/TogglJira/src/Command/SyncCommand.php(64): TogglJira\Service\SyncService->sync(Object(DateTime), Object(DateTime), false)
#4 /usr/src/toggl-jira/module/TogglJira/src/Handler/CommandHandler.php(55): TogglJira\Command\SyncCommand->execute(Object(Zend\Console\Request), Object(Zend\Console\Adapter\Posix))
#5 [internal function]: TogglJira\Handler\CommandHandler->__invoke(Object(ZF\Console\Route), Object(Zend\Console\Adapter\Posix))
#6 /usr/src/toggl-jira/vendor/zfcampus/zf-console/src/Dispatcher.php(107): call_user_func(Object(TogglJira\Handler\CommandHandler), Object(ZF\Console\Route), Object(Zend\Console\Adapter\Posix))
#7 /usr/src/toggl-jira/vendor/zfcampus/zf-console/src/Application.php(215): ZF\Console\Dispatcher->dispatch(Object(ZF\Console\Route), Object(Zend\Console\Adapter\Posix))
#8 /usr/src/toggl-jira/vendor/zfcampus/zf-console/src/Application.php(168): ZF\Console\Application->processRun(Array)
#9 /usr/src/toggl-jira/bin/toggljira.php(11): ZF\Console\Application->run()
#10 {main}

To Reproduce Steps to reproduce the behavior:

  1. Create an entry like the above in Toggl and sync it.
  2. Run the script with a --start option that includes the date of the Toggl entry.

Expected behavior Script runs and entries are synced. If there is no ABCD-1234 issue in JIRA, the script still syncs other time logs.

Additional context I was able to work around this by just editing the Toggl entries that caused it. I'm thinking a good solution would be an additional configuration option to specify which projects should be synced. Alternatively, the script could query JIRA to check which projects at the configured URL the user actually has access to (and their issue prefixes) and then discard any non-matching time logs. I might try to do this if I keep bumping up against this. Thought to just file a bug report for now.

AxaliaN commented 5 years ago

I am not currently using/updating this anymore, so feel free to create a PR and fix this issue :)