Skip to content

fix: catch an empty recording date instead of crashing in datestr - #34

Merged
tabedzki merged 1 commit into
mainfrom
tabedzki/fix/recording-date-nat
Oct 23, 2026
Merged

tabedzki merged 1 commit into
mainfrom
tabedzki/fix/recording-date-nat

Conversation

@tabedzki

@tabedzki tabedzki commented Oct 22, 2026 •

Copy link
Copy Markdown
Contributor

🤖 AI text below 🤖

Fixes #33

Problem
Registering a recording without a behavior session crashed in createRecording (line 87) with "DATESTR failed converting date number to date vector. Date number out of range." The Recording Date picker hadn't been set, so its value was NaT, and that went straight to datestr. The crash happened before any error dialog, so the busy label stayed on.

Fix

  • buildRecordingDatetime.m (new) checks that a date was picked (not empty, not NaT) and that the hour spinner is between 0 and 24. It then builds recording_datetime and the cup session_date with datetime arithmetic, so hour 24 rolls over to the next day instead of wrapping back to 00:xx on the same date.
  • createRecording calls it. If the date or hour is invalid, the user gets an error dialog, the button is re-enabled and the busy label clears. No Slack message is sent for this.
  • checkParamSelection now passes event to createRecording. Before, any createRecording error handler that ran on this path would have failed on event.Source.

Tests

  • tests/TestBuildRecordingDatetime.m covers:
    • the reported case: a NaT date
    • an empty date
    • hour 0, hour 24 rolling over, and fractional minutes
    • a time of day already set on the picked date
    • a negative hour, an hour over 24, and a NaN or empty hour
  • It's added to the MATLAB CI job and to the test commands in AGENTS.md and README.md.
  • MATLAB isn't installed on the agent's machine, so the tests haven't run yet, and I couldn't watch the new test fail on 670e661d. On that commit the NaT value went straight to datestr, as in the reported traceback. CI will be the first run.
  • Lint (prek) passes.

Note
Rebased onto main after #36. The date check now sits inside #36's try/catch for the steps before the copy. It keeps its own catch, so a missing date gets an error dialog but no Slack message: the user can fix that themselves.

Assisted-by: ClaudeCode:claude-opus-5-5

Registering a recording without a behavior session crashed with
"DATESTR failed converting date number to date vector. Date number out
of range." at createRecording line 87: the Recording Date picker was
never set, so its Value was NaT and went straight to datestr.

buildRecordingDatetime now validates the date (not empty or NaT) and
the hour (0-24) and combines them with datetime arithmetic, so hour 24
rolls over to the next day instead of wrapping on the same date.
createRecording shows the problem in a dialog, re-enables the button
and clears the busy label. checkParamSelection now passes event to
createRecording, which its error handlers need.

Fixes #33

Assisted-by: ClaudeCode:claude-opus-5-5
@tabedzki
tabedzki force-pushed the tabedzki/fix/recording-date-nat branch from 09ddfda to 02ff599 Compare October 23, 2026 00:42
@tabedzki
tabedzki marked this pull request as ready for review October 23, 2026 00:42
@tabedzki
tabedzki merged commit a775e9a into main Oct 23, 2026
7 checks passed
@tabedzki
tabedzki deleted the tabedzki/fix/recording-date-nat branch October 23, 2026 00:45
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.

[BUG] createRecording crashes with 'Date number out of range' when no recording date is picked

1 participant