Skip to content

API: Throw an error when request json has invalid fields #359

@andreeaflorescu

Description

@andreeaflorescu

Right now, if a json has an invalid field in it, serde does not throw an error. The deserializer just skips that field.
For example, if you want to configure the VM with vcpu_count=3 and mem_size_mib=256, but you reverse two letters (which isn't exactly unlikely), the request will be successful, but only the vcpu_count will be updated in this example:

curl --unix-socket /tmp/firecracker.socket -i -X GET "http://localhost/machine-config" -H "accept: application/json" -H "Content-Type: application/json" => {"vcpu_count": 1, "mem_size_mib": 128 ...}

curl --unix-socket /tmp/lambda.socket -i
-X PUT "http://localhost/machine-config"
-H "accept: application/json"
-H "Content-Type: application/json"
-d "{
"vcpu_count": 3,
"mem_size_mbi": 3906,
}"

curl --unix-socket /tmp/firecracker.socket -i -X GET "http://localhost/machine-config" -H "accept: application/json" -H "Content-Type: application/json" => {"vcpu_count": 3, "mem_size_mib": 128 ...}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions