Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix error handling / messaging on import validation errors. #2707

Merged
merged 1 commit into from
Sep 29, 2024

Conversation

meisterT
Copy link
Member

Fixes #2705.

While we are at it, also improve the usefulness of the error messages.

Example:

image

Command line:

webapp/bin/console api:call -m POST -f json=../Downloads/organizations.json users/organizations
04:17:58 ERROR     [request] Uncaught PHP Exception Symfony\Component\HttpKernel\Exception\BadRequestHttpException: "Error while adding organizations: Organization at index 36 ({"externalid":"U-3397","shortname":"","name":"Chalmers University of Technology","country":"SWE","icpc_id":null}) has errors:
  • `shortname`: This value should not be blank.

Organization at index 42 ({"externalid":"U-3758","shortname":"","name":"King's College London","country":"GBR","icpc_id":null}) has errors:
  • `shortname`: This value should not be blank.

Organization at index 67 ({"externalid":"U-8102","shortname":"","name":"University of Passau","country":"DEU","icpc_id":null}) has errors:
  • `shortname`: This value should not be blank.

" at UserController.php line 131 ["exception" => Symfony\Component\HttpKernel\Exception\BadRequestHttpException^ { …}]

Copy link

sentry-io bot commented Sep 21, 2024

🔍 Existing Issues For Review

Your pull request is modifying functions with the following pre-existing issues:

📄 File: webapp/src/Service/ImportExportService.php

Function Unhandled Issue
App\Service\ImportExportService::importGroupData TypeError: App\Entity\TeamCategory::setAllowSelfRegistration(): Argument #1 ($allowSelfRegistration) must be... /src/Entity/TeamCa...
Event Count: 1

Did you find this useful? React with a 👍 or 👎

Copy link
Member

@eldering eldering left a comment

Choose a reason for hiding this comment

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

Just a comment that the spec does not have shortname, only name and formal_name, see https://ccs-specs.icpc.io/draft/contest_api#organizations, so the error message is a bit confusing since it refers to internal attribute names, not the ones from the spec.

Fixes DOMjudge#2705.

While we are at it, also improve the usefulness of the error messages.
@meisterT
Copy link
Member Author

Just a comment that the spec does not have shortname, only name and formal_name, see https://ccs-specs.icpc.io/draft/contest_api#organizations, so the error message is a bit confusing since it refers to internal attribute names, not the ones from the spec.

Yep, since error handling is a little bit opaque it is kinda non-trivial to change though. I will merge this as it is clearly better than a silent failure and then we can discuss with Nicky when he is back how to best improve it.

@meisterT meisterT added this pull request to the merge queue Sep 29, 2024
Merged via the queue into DOMjudge:main with commit 9137d92 Sep 29, 2024
26 checks passed
@meisterT meisterT deleted the fix2705 branch September 29, 2024 12:51
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.

Import of organizations.json broken
3 participants