Skip to content

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

Open
abdimo101 wants to merge 2 commits intomasterfrom
fix-date-type-metadata-view
Open

fix: prevent numerical metadata values from being incorrectly formatted as dates#2213
abdimo101 wants to merge 2 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
Comment on lines +243 to +244
if (scientificMetadata.type) {
return scientificMetadata.type === "date";
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.

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