chirpstack-application-server icon indicating copy to clipboard operation
chirpstack-application-server copied to clipboard

Swagger docs misleading on "id" field

Open maxgerhardt opened this issue 3 years ago • 0 comments
trafficstars

  • [x] The issue is present in the latest release.
  • [x] I have searched the issues of this repository and believe that this is not a duplicate.

What happened?

Swagger docs on /swagger/#!/DeviceProfileService/Create show that the API accepts an "id" field

image

But doing a request with that "id" field set to a specific UUID does not create the device profile under that given UUID, but a new random one.

What did you expect?

Device profile is created with "id" sourced from the API request.

Instead, code is hardcoded to ignore the "id" field and create a new UUID for every newly created device profile, see

https://github.com/brocaar/chirpstack-application-server/blob/9cf39fdda404e71744fa4f84a1cf26bf63a9b4aa/internal/api/external/device_profile.go#L98-L102

and

https://github.com/brocaar/chirpstack-application-server/blob/9cf39fdda404e71744fa4f84a1cf26bf63a9b4aa/internal/storage/device_profile.go#L59-L76

Steps to reproduce this issue

Steps:

  1. Startup chirpstack services
  2. Obtain login token via /internal/login API
  3. Execute POST request on /api/device-profiles using JSON payload {'deviceProfile': {'adrAlgorithmID': 'default', 'factoryPresetFreqs': [868100000, 868300000, 868500000, 867100000, 867300000, 867500000, 867000000, 867900000], 'id': '19990b47-496e-4d82-a136-c0e6b208c401', 'macVersion': '1.0.2', 'maxEIRP': 12, 'name': 'OTAA', 'networkServerID': '1', 'organizationID': '1', 'regParamsRevision': 'B', 'rxDataRate2': 3, 'rxDelay1': 1, 'rxFreq2': 869525000, 'supportsClassB': False, 'supportsClassC': False, 'supportsJoin': True, 'tags': {}, 'uplinkInterval': '86400s'}} and previously obtained authentication token
  4. Observe and check whether the returned API response's "id" field is equal to the wanted one (19990b47-496e-4d82-a136-c0e6b208c401)

Could you share your log output?

docker_env_initializer-chirpstack-network-server-1      | time="2022-05-24T11:20:27.018020527Z" level=info msg="finished unary call with code OK" ctx_id=f1e56bfb-4dea-46f4-aa54-21e3ff8f0cec grpc.code=OK grpc.method=CreateDeviceProfile grpc.service=ns.NetworkServerService grpc.start_time="2022-05-24T11:20:27Z" grpc.time_ms=1.138 peer.address="172.23.0.7:50636" span.kind=server system=grpc
docker_env_initializer-chirpstack-application-server-1  | time="2022-05-24T11:20:27.018256939Z" level=info msg="finished client unary call" ctx_id=d4489dbf-2ff6-414c-89bd-c50067e09ce9 grpc.code=OK grpc.ctx_id=f1e56bfb-4dea-46f4-aa54-21e3ff8f0cec grpc.duration=1.69279ms grpc.method=CreateDeviceProfile grpc.service=ns.NetworkServerService span.kind=client system=grpc
docker_env_initializer-chirpstack-application-server-1  | time="2022-05-24T11:20:27.018306589Z" level=info msg="device-profile created" ctx_id=d4489dbf-2ff6-414c-89bd-c50067e09ce9 id=55832e6d-47a2-4f04-85a3-ce88bb8a3f52
docker_env_initializer-chirpstack-application-server-1  | time="2022-05-24T11:20:27.018822987Z" level=info msg="finished unary call with code OK" ctx_id=d4489dbf-2ff6-414c-89bd-c50067e09ce9 grpc.code=OK grpc.method=Create grpc.service=api.DeviceProfileService grpc.start_time="2022-05-24T11:20:27Z" grpc.time_ms=4.836 peer.address="127.0.0.1:57656" span.kind=server system=grpc

Your Environment

Latest ones you get through https://github.com/brocaar/chirpstack-docker/

Component Version
Application Server v3
Network Server v3
Gateway Bridge v3
Chirpstack API -/-
Geolocation -/-
Concentratord -/-

maxgerhardt avatar May 24 '22 11:05 maxgerhardt