TheThingsNetwork / lorawan-stack

The Things Stack, an Open Source LoRaWAN Network Server
https://www.thethingsindustries.com/stack/
Apache License 2.0
992 stars 309 forks source link

Notify the users about ineffective fields in queued application downlink #1771

Open rvolosatovs opened 4 years ago

rvolosatovs commented 4 years ago

Summary

AS should notify the users about ineffective fields in queued application downlink

Why do we need this?

In order to avoid issues like https://github.com/TheThingsNetwork/lorawan-stack/issues/1757, where typos/mistakes in JSON cause unexpected behavior for users

What is already there? What do you see now?

Ineffective fields in application downlink JSON are silently ignored and downlink is scheduled

What is missing? What do you want to see?

Ineffective fields in application downlink JSON should be communicated to the user in some way, for example, by triggering an event. See https://github.com/TheThingsNetwork/lorawan-stack/issues/1757#issuecomment-567961412 as well.

How do you propose to implement this?

Use the json.Decoder with DisallowUnknownFields first and if that fails, try json.Unmarshal - if 2nd unmarshal succeeds, trigger an event or send a response back to the user while queuing the unmarshaled message.

Can you do this yourself and submit a Pull Request?

yes

johanstokking commented 4 years ago

This should be in;