oxidecomputer / oxide.rs

The Oxide Rust SDK and CLI
Mozilla Public License 2.0
37 stars 12 forks source link

Don't quote string values in query parameters #747

Closed wfchandler closed 1 month ago

wfchandler commented 1 month ago

We read string values into a serde_json::Value::String when parsing parameters, using its Display format when appending {key}={value} to the URI. This is incorrect as Value::String encloses the value with double quotes.

Use the as_str() method to write string values to query parameters.

Full URI before:

https://oxide.sys.example.com/v1/instances?project=\"will\"

Full URI after:

https://oxide.sys.example.com/v1/instances?project=will

Also, currently we only check for params added via -f/--raw-field and -F/field when self.input is not empty. It is valid to pass parameters when no body has been set, check for params independently of input.

wfchandler commented 1 month ago

why were you using oxide api?

@ahl it's more convenient that manually setting the url and auth headers for curl. I think it's a nice feature, are we planning on removing it?

ahl commented 1 month ago

why were you using oxide api?

@ahl it's more convenient that manually setting the url and auth headers for curl. I think it's a nice feature, are we planning on removing it?

Not planning on removing it and it's intended to be more convenient than curl... but my hope is that it's rarely needed. May I ask what you were using it for?

wfchandler commented 1 month ago

In this case I was using it to print large amounts of text from the CLI to validate that the fix in #746 was working correctly.

I also used it recently for adding a silo cert in the context of https://github.com/oxidecomputer/docs/pull/398.