Treat an omitted executeTool() input as an empty object - #324
Conversation
|
Sorry for missing this bit in https://github.com/webmachinelearning/webmcp/pull/251/changes. @domfarolino WDYT? |
domfarolino
left a comment
There was a problem hiding this comment.
Thanks, yeah I think this is a bug. The behavior I really wanted in https://crrev.com/c/8250826/comment/43a901d5_d0bb54d8/ was:
- Missing input arguments would be treated just like
executeTool(tool, {}). - Explicitly passing
undefined, as inexecuteTool(tool, undefined), would throw an exception.
But Web IDL intentionally treats missing undefined and explicit undefined for optional arguments (with no default) as "missing", so I don't think we can achieve my desired distinction without introducing an overload:
executeTool(tool, options)
executeTool(tool, object inputArguments, options)But that's not very clean, and I'm not sure it's worth fighting Web IDL's defaults here. So I'm happy with the direction of this PR: converge missing-undefined and explicit-undefined. See the two notes below.
|
Alright I've pushed up a few changes to address the above. Would like one more person on this thread to give an LGTM and I think we can merge. |
|
LGTM! Thanks folks |
|
I dropped this from the agenda since we're aligned and can land this fix soon. Thanks for the PR! |
b516e80 to
f955442
Compare
SHA: 294bad9 Reason: push, by domfarolino Co-authored-by: github-actions[bot] <41898282+github-actions[bot]@users.noreply.github.com>
@domfarolino @beaufortfrancois I ran into this while writing the polyfill. Not sure what the intended behavior is, but I prefer the fallback:
clanker with the details below:
Right now the spec says calling
executeTool(tool)with no input throws aTypeError, but Chrome and WPT run the tool with{}.The spec used to default to
{}too. #251 changed the input's type toanyand first kept the default as a step (45afd88), but its last commit removed that step (b755b64) when Chromium moved the default into its C++ code. This PR puts the step back.One wrinkle: the CL review wanted an explicit
undefinedto throw, but Web IDL treats it the same as a missing argument, soexecuteTool(tool, undefined)gets{}too. Chrome already does this.Preview | Diff