Skip to content

fix: prevent numerical metadata values from being incorrectly formatted as dates#2213

Merged
abdimo101 merged 11 commits intomasterfrom
fix-date-type-metadata-view
Feb 18, 2026
Merged

fix: prevent numerical metadata values from being incorrectly formatted as dates#2213
abdimo101 merged 11 commits intomasterfrom
fix-date-type-metadata-view

Conversation

@abdimo101
Copy link
Member

@abdimo101 abdimo101 commented Feb 4, 2026

Description

This PR fixes a bug where numeric metadata values (like "10") were being incorrectly displayed as dates (like "1970-01-01 01:00") in the metadata view table. The fix ensures that when metadata has a type field set (such as "number" or "quantity"), that type is respected and the value is displayed correctly.

Motivation

Background on use case, changes needed

Fixes:

Please provide a list of the fixes implemented in this PR

  • Items added

Changes:

Please provide a list of the changes implemented by this PR

  • changes made

Tests included

  • Included for each change/fix?
  • Passing? (Merge will not be approved unless this is checked)

Documentation

  • swagger documentation updated [required]
  • official documentation updated [nice-to-have]

official documentation info

If you have updated the official documentation, please provide PR # and URL of the pages where the updates are included

Backend version

  • Does it require a specific version of the backend
  • which version of the backend is required:

Summary by Sourcery

Bug Fixes:

  • Respect the explicit metadata type field when determining if a value is a date so that numeric and other non-date values are no longer misinterpreted and displayed as dates.

@abdimo101 abdimo101 requested a review from a team as a code owner February 4, 2026 13:47
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

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

Hey - I've reviewed your changes and they look great!


Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment and I'll use the feedback to improve your reviews.

@abdimo101 abdimo101 requested a review from Junjiequan February 4, 2026 13:58
FloKo2669
FloKo2669 previously approved these changes Feb 5, 2026
Comment on lines 243 to 244
Copy link
Member

@Junjiequan Junjiequan Feb 6, 2026

Choose a reason for hiding this comment

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

I'm not sure about this change, previous code returns only when type is date but with this change it returns when type exist. Is it really the fix? Are you sure that the codes below should not executed when there is type?

Copy link
Contributor

Choose a reason for hiding this comment

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

To my understanding the purpose is to check if the value is a date. So if it has a type, which is not Date, it is not necessary to run the code below because it shouldn't be a date. But if the type is undefined, the code below has to check if it is a date. Of course this assumes that the type is set correctly.

And the old code would turn "2010" into a Date because new Date("2010").toString() is a valid date. However, I just noticed, that if the type is not defined, the 2010 would still be interpreted as a Date, which would still be wrong. So the heuristic below needs to be stricter?
Or am I missing something?

Copy link
Member

@Junjiequan Junjiequan Feb 6, 2026

Choose a reason for hiding this comment

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

Unfortunately, the type concept exists only on the frontend. On the backend we do not constraint users from creating any arbitary scientific metadata with any values regardless of the type.

It means that, User can create any type of date. It could be string date, numeric date(timestamp) , date date, but of course most cases user don't provide type at all, since its not required.

Hence I don't see this PR fixes the root. Stricter validation could be one way.

Copy link
Member Author

Choose a reason for hiding this comment

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

It is true that this PR only works when the type is set correctly, because the main purpose was to prevent numerical values with types like "number" and "quantity" from being incorrectly formatted as dates.

But after reading both of your comments, I understand that we need stricter validation to handle cases where:

  1. Type is not set
  2. Type might be set incorrectly

@FloKo2669 FloKo2669 dismissed their stale review February 9, 2026 08:52

agree with changes requested

@abdimo101
Copy link
Member Author

After discussing with the team, we have decided to remove the isDate check, which would prevent unintended conversion of numerical values to dates.

A follow-up PR will be created to add cypress tests covering various metadata type scenarios and edge cases.

@abdimo101 abdimo101 enabled auto-merge (squash) February 11, 2026 16:11
@abdimo101 abdimo101 disabled auto-merge February 18, 2026 12:28
@Junjiequan
Copy link
Member

Please test it locally to check if it breaks anything before merging

@abdimo101 abdimo101 merged commit 6875189 into master Feb 18, 2026
8 checks passed
@abdimo101 abdimo101 deleted the fix-date-type-metadata-view branch February 18, 2026 14:48
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.

3 participants

Comments