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

Swagger docs misleading on "id" field #686

Open
2 tasks done
maxgerhardt opened this issue May 24, 2022 · 0 comments
Open
2 tasks done

Swagger docs misleading on "id" field #686

maxgerhardt opened this issue May 24, 2022 · 0 comments

Comments

@maxgerhardt
Copy link

maxgerhardt commented May 24, 2022

  • The issue is present in the latest release.
  • 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

// as this also performs a remote call to create the device-profile
// on the network-server, wrap it in a transaction
err = storage.Transaction(func(tx sqlx.Ext) error {
return storage.CreateDeviceProfile(ctx, tx, &dp)
})

and

func CreateDeviceProfile(ctx context.Context, db sqlx.Ext, dp *DeviceProfile) error {
if err := dp.Validate(); err != nil {
return errors.Wrap(err, "validate error")
}
dpID, err := uuid.NewV4()
if err != nil {
return errors.Wrap(err, "new uuid v4 error")
}
now := time.Now()
dp.DeviceProfile.Id = dpID.Bytes()
dp.CreatedAt = now
dp.UpdatedAt = now
_, err = db.Exec(`
insert into device_profile (
device_profile_id,

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 -/-
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

No branches or pull requests

1 participant