Skip to content

[25.1] Fix timestamp parsing in job import/export#22372

Merged
mvdbeek merged 1 commit intogalaxyproject:release_25.1from
mvdbeek:fix_datetime_restore
Apr 3, 2026
Merged

[25.1] Fix timestamp parsing in job import/export#22372
mvdbeek merged 1 commit intogalaxyproject:release_25.1from
mvdbeek:fix_datetime_restore

Conversation

@mvdbeek
Copy link
Copy Markdown
Member

@mvdbeek mvdbeek commented Apr 2, 2026

Use datetime.fromisoformat() instead of strptime with a rigid format that requires microseconds. When datetime.isoformat() produces timestamps without microseconds (e.g. "2026-04-02T14:28:40"), the strptime format "%Y-%m-%dT%H:%M:%S.%f" fails silently, leaving update_time/create_time as None on the restored model object.

The try/except: pass was silently swallowing parse errors for 5 years, making it hard to debug when timestamps failed to restore. Just check for key presence instead — if the value exists but is malformed, let it fail loudly.
These fields are required by downstream code, so silently skipping them just delays the failure. Let KeyError or ValueError surface at the actual point of failure.

Fixes #22371

How to test the changes?

(Select all options that apply)

  • I've included appropriate automated tests.
  • This is a refactoring of components with existing test coverage.
  • Instructions for manual testing are as follows:
    1. [add testing steps and prerequisites here if you didn't write automated tests covering all your changes]

License

  • I agree to license these and all my past contributions to the core galaxy codebase under the MIT license.

Use datetime.fromisoformat() instead of strptime with a rigid format
that requires microseconds. When datetime.isoformat() produces
timestamps without microseconds (e.g. "2026-04-02T14:28:40"), the
strptime format "%Y-%m-%dT%H:%M:%S.%f" fails silently, leaving
update_time/create_time as None on the restored model object.

Also guard against None timestamps on the export side to prevent
AttributeError when update_time or create_time is None.

The try/except: pass was silently swallowing parse errors for 5 years,
making it impossible to debug when timestamps failed to restore. Just
check for key presence instead — if the value exists but is malformed,
let it fail loudly.
These fields are required by downstream code, so silently skipping
them just delays the failure. Let KeyError or ValueError surface
at the actual point of failure.

Fixes galaxyproject#22371
@github-project-automation github-project-automation Bot moved this to Needs Review in Galaxy Dev - weeklies Apr 2, 2026
@github-actions github-actions Bot added the area/database Galaxy's database or data access layer label Apr 2, 2026
@github-actions github-actions Bot added this to the 26.1 milestone Apr 2, 2026
Copy link
Copy Markdown
Member

@natefoo natefoo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I will approve/merge any removal of silent try: except: pass without further analysis. 😆

@mvdbeek mvdbeek merged commit 84506e3 into galaxyproject:release_25.1 Apr 3, 2026
51 of 54 checks passed
@github-project-automation github-project-automation Bot moved this from Needs Review to Done in Galaxy Dev - weeklies Apr 3, 2026
@github-actions
Copy link
Copy Markdown

github-actions Bot commented Apr 3, 2026

This PR was merged without a "kind/" label, please correct.

@nsoranzo nsoranzo deleted the fix_datetime_restore branch April 3, 2026 13:33
@ahmedhamidawan ahmedhamidawan modified the milestones: 26.1, 26.0 Apr 6, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

area/database Galaxy's database or data access layer kind/bug

Projects

Development

Successfully merging this pull request may close these issues.

3 participants