[CONTROLLER-331] toaster:make-toast RPC allows invalid ToastType Created: 16/Apr/14  Updated: 25/Jul/23  Resolved: 01/Jul/14

Status: Resolved
Project: controller
Component/s: restconf
Affects Version/s: None
Fix Version/s: None

Type: Bug
Reporter: Tom Pantelis Assignee: Tom Pantelis
Resolution: Done Votes: 0
Labels: None
Remaining Estimate: Not Specified
Time Spent: Not Specified
Original Estimate: Not Specified
Environment:

Operating System: Linux
Platform: PC


External issue ID: 762

 Description   

While invoking make-toast RPC, I specified an incorrect toasterToastType, ie "wheat-toast" instead of "wheat-bread":

{
"toaster:input" :

{ "toaster:toasterDoneness" : "3", "toaster:toasterToastType" : "wheat-toast" }

}

It got into the OpendaylightToaster.makeToast method fine although it threw an NPE because toastType was null. However since the toast type was invalid it should have been caught earlier and an exception thrown. The transformation from DOM input to MakeToastInput is done in a BindingCodec class that is generated on-the-fly from the MakeToastInput interface. The generated code actually calls LazyGeneratedCodecRegistry::IdentityCompositeCodec.deserialize which looks up the given "wheat-toast" qname in the qnamesToIdentityMap and just returns null if not found. It seems this method should throw an IllegalArgumentEx.



 Comments   
Comment by Tom Pantelis [ 24/May/14 ]

Pushed https://git.opendaylight.org/gerrit/#/c/7367.

Also added verification in the Bits, Union, and Enum TypeDefinitionAwareCodecs.

Generated at Wed Feb 07 19:52:46 UTC 2024 using Jira 8.20.10#820010-sha1:ace47f9899e9ee25d7157d59aa17ab06aee30d3d.