Altinn / Altinn/app-frontend-react

Frontend throws error when using a XSD uploaded with `xsd:gYear` type

Open
#2,023 0 comments 0 reactions 0 assignees View on GitHub
area/data-storage kind/bug status/for-consideration
Dominant language
TypeScript
Stars
21
Forks
33
Avg merge
6d 23h
Merged PRs (30d)
3

Description

### Description of the bug

Frontend throws error when using a XSD uploaded with `xsd:gYear` type

Uploaded XSD:
```xsd




```

The error:
```js
Error: "formatMaximum": format "year" does not define "compare" function
```

Schema generated:
```json
"RegnskapAr-17102_Verdirestriksjon": {
"@xsdType": "gYear",
"type": "string",
"format": "year",
"@xsdStructure": "XmlSchemaSimpleTypeRestriction",
"formatMinimum": "1980",
"formatMaximum": "9999",
"@xsdUnhandledAttributes": {
"seres:elementtype": "Tallrestriksjon"
}
}
```

### Steps To Reproduce

1. Upload a XSD with "gYear" as specified in the description and generate models
2. The app should crash when loading

### Additional Information

The XSD is a part of imgrate migrating 2 to 3.

Slack discussion with example XSD: https://altinn.slack.com/archives/C02EJ9HKQA3/p1713166049825899
Duplicate issue with more information: https://github.com/Altinn/app-frontend-react/issues/856

Contributor guide

Open the contributing guide

Research direction

Start by reproducing the crash with the uploaded XSD containing an xsd:gYear restriction and the generated schema shown in the issue. Trace the handling of formatMaximum for the year format; done means loading and generating models no longer throws the reported compare-function error. Review the linked duplicate issue for additional context.

Written by the indexing model from the issue text.

Assessment

Tech stack
react, typescript
Domain
frontend
Issue type
Bug
Difficulty
3/5
Estimated time
1-2 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.