DOMjudge / domjudge

DOMjudge programming contest jury system
https://www.domjudge.org
GNU General Public License v2.0
709 stars 248 forks source link

API: External ID for Group entity cannot be set via API #2381

Closed baierjan closed 4 months ago

baierjan commented 4 months ago

Description of the problem

Similar problem to #2186; when using data_source=1 (i.e. configuration data external), Group entity (a.k.a. Team Categories) is created without externalid when using api endpoint /api/v4/contests/{cid}/groups.

Your environment

DOMjudge 8.3.0DEV/30f885875

Steps to reproduce

Expected behaviour

External id can be set via API call or is automatically created. Like in the Teams entity, id attribute could be included in the API call: curl -XPOST https://domserver/api/v4/contests/demo/groups -Fid=1234 -Fname=demo -Ficpc_id=1234 and that should set the external id if using configuration data external mode.

{"hidden":false,"id":1234,"icpc_id":"1234","name":"test","sortorder":0,"color":null,"allow_self_registration":false}

Actual behaviour

API call returns:

{"hidden":false,"id":null,"icpc_id":"1234","name":"test","sortorder":0,"color":null,"allow_self_registration":false}

No external id for the entity is created and the configuration checker shows an error "Team category XY does not have an external ID" which needs to be fixed by manually editing all entities via GUI.

nickygerritsen commented 4 months ago

Good catch. We internally normally don't use these endpoints but /api/v4/users/organizations, but I agree that the other endpoints should accept ID's when using a data source other than 0.

baierjan commented 4 months ago

Yep, using /api/v4/users/organizations works as expected, so it could be used as a quick workaround, one just need to batch all groups into one array and POST it together. Thanks!

nickygerritsen commented 4 months ago

I am already working on a fix, so should be there soon ™️

baierjan commented 4 months ago

No need to hurry, as the workaround is working well, this issue is not at all critical.

nickygerritsen commented 4 months ago

Note that for this endpoint, we can't allow ID, since that is against the CLICS spec, see https://ccs-specs.icpc.io/draft/contest_api#http-methods.

But instead, we can add a PUT to a specific entity, which I will implement.