Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -240,20 +240,16 @@ export class MetadataViewComponent implements OnInit, OnChanges {

isDate(scientificMetadata: ScientificMetadataTableData): boolean {
// NOTE: If the type is date, we expect the value to be in ISO format.
if (scientificMetadata.type === "date") {
return true;
if (scientificMetadata.type) {
return scientificMetadata.type === "date";
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.

}

const isValidDate =
typeof scientificMetadata.value !== "number" &&
new Date(scientificMetadata.value).toString() !== "Invalid Date" &&
DateTime.fromISO(scientificMetadata.value).isValid;

if (isValidDate) {
return true;
}

return false;
return isValidDate;
}

ngOnInit() {
Expand Down
Loading