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

Allow unsetting (deleting) parameters #145

Merged
merged 1 commit into from Feb 13, 2023
Merged

Conversation

achim-k
Copy link
Collaborator

@achim-k achim-k commented Feb 3, 2023

Public-Facing Changes

  • Allow unsetting (deleting) parameters

Description
Implements the specification update in foxglove/ws-protocol#354

Comment on lines +33 to +36
if (j.find("value") == j.end()) {
p = Parameter(name); // Value is not set (undefined).
return;
}
Copy link
Collaborator Author

@achim-k achim-k Feb 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think it would be more explicit if the value was set to null (nlohmann::detail::value_t::null)

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't understand the comment here, null and undefined are not the same thing.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I was referring to foxglove/ws-protocol#354 (comment), where we chose to use undefined (no value provided) instead of null.

@@ -974,7 +974,14 @@ template <typename ServerConfiguration>
inline void Server<ServerConfiguration>::publishParameterValues(
ConnHandle hdl, const std::vector<Parameter>& parameters,
const std::optional<std::string>& requestId) {
nlohmann::json jsonPayload{{"op", "parameterValues"}, {"parameters", parameters}};
// Filter out parameters which are not set.
Copy link
Collaborator Author

@achim-k achim-k Feb 3, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The spec currently does not declare what parameter message to expect when requesting a non-existing / deleted parameter. Should it be

{
  "op": "parameterValues", 
  "parameters": []
}

or

{
  "op": "parameterValues", 
  "parameters": [{ "name": "/deleted_param" }]
}

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The second example is not valid JSON. There is no undefined literal in https://www.rfc-editor.org/rfc/rfc8259

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Adapted my first comment by removing the value field

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the first is better?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OK, that's also how it is currently implemented

@achim-k
Copy link
Collaborator Author

achim-k commented Feb 9, 2023

@jhurliman OK for you to merge as is?

@achim-k achim-k merged commit 35b98d6 into main Feb 13, 2023
@achim-k achim-k deleted the achim/allow_deleting_params branch February 13, 2023 17:34
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants