Skip to content

Map some container model errors for the container creation form. - #1204

Merged
UlysseFG merged 7 commits into
masterfrom
container-creation-error
Oct 15, 2026
Merged

UlysseFG merged 7 commits into
masterfrom
container-creation-error

Conversation

@UlysseFG

Copy link
Copy Markdown
Collaborator

No description provided.

@UlysseFG
UlysseFG requested a review from nafiz1001 September 30, 2026 21:50
@UlysseFG

Copy link
Copy Markdown
Collaborator Author

The migration is some model alterations that were not made (forgotten) during last release (small mismatch).

Comment thread backend/fms_core/viewsets/container.py Outdated
Comment on lines +128 to +131
for error in errors:
for pattern, field in patterns:
if re.fullmatch(pattern, error):
raise ValidationError({field: ",".join(errors)})

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

So if there is coordinate error, we assume all errors are related to coordinate?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

Well there is potentially more than one error but these are the ones that are likely to creep up here if additional error arise and are not caught you'll add them to whatever get assigned ... if nothing get assigned it will be listed under barcode ...

Maybe i should just liste the error matching and once they fix it they would get another one ...

Comment thread backend/fms_core/viewsets/container.py Outdated
Comment on lines +128 to +132
for error in errors:
for pattern, field in patterns:
if re.fullmatch(pattern, error):
raise ValidationError({field: error})
raise ValidationError({"barcode": ",".join(errors)}) # Default errors to the Barcode form field until we map it.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Can't you have a dictionary that collects errors for coordinate and barcode?

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

You need to say more to say anything ... This is already a dictionary with coordinate or barcode error.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

😪
To clarify what I'm saying, you are returning error either for barcode or coordinate. Why not with both kinds of errors at once?

@nafiz1001 nafiz1001 Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Like loop over each error, if you come across a barcode error errors["barcode"] = ..., if it's a coordinate error errors["coordinate"] = .... And then return errors at the end of the loop.

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

ok I am not sure if this would be the best way to present it in the frontend ... The form will list the errors that match the fields. If more than one error match you would likely get a absurdedly long error line to parse. The Barcode is just a catchall category to make sure the error message displays on the form.

@UlysseFG UlysseFG Oct 6, 2026 •

Copy link
Copy Markdown
Collaborator Author

Choose a reason for hiding this comment

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

I will parse through the whole set of errors. For now there is no clash to be expected anyway ...

Comment thread backend/fms_core/viewsets/container.py Outdated
Comment on lines +131 to +132
if re.fullmatch(pattern, error):
parsed_errors[field] += error

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

At least a space between errors?

@UlysseFG
UlysseFG requested a review from nafiz1001 October 13, 2026 21:44
Comment on lines 110 to 112
.then(() => { setFormErrors({}) })
.catch(err => { setFormErrors(err.data || {}) })
.then(() => Promise.all([refreshTable()]))

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

I wonder if .then(() => { setFormErrors({}) }) is even useful since you'd be redirected to another page anyway.

@UlysseFG
UlysseFG merged commit c9a6965 into master Oct 15, 2026
5 checks passed
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.

2 participants