-
Notifications
You must be signed in to change notification settings - Fork 911
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
Datastore cleanup and bugfix #5994
Datastore cleanup and bugfix #5994
Conversation
People get upset, especially as our "not found" error can be a bit hard to read! Signed-off-by: Rusty Russell <[email protected]> See-also: ElementsProject#5990
@rustyrussell |
This 'fixes' the testcases (e.g. I could not find the code where the diff --git a/common/json_param.c b/common/json_param.c
index 7aa217464..e8e9bf3ff 100644
--- a/common/json_param.c
+++ b/common/json_param.c
@@ -417,7 +417,7 @@ struct command_result *param_escaped_string(struct command *cmd,
const jsmntok_t *tok,
const char **str)
{
- if (tok->type == JSMN_STRING) {
+ if (tok->type == JSMN_STRING || tok->type == JSMN_PRIMITIVE) {
struct json_escape *esc;
/* jsmn always gives us ~ well-formed strings. */
esc = json_escape_string_(cmd, buffer + tok->start, |
8c4aa7f
to
1dd29ea
Compare
Yes, the previous code would accept anything. But that's clearly a bug, we should insist that a parameter called "string" be a string? Indeed, fixed. |
…datastore". This only worked because we handled the JSON raw: next patch prohibits this. Signed-off-by: Rusty Russell <[email protected]>
We were feeding in the raw JSON, which escapes \". Then we were escaping *again* to return it. Reported-by: @m-schmook Signed-off-by: Rusty Russell <[email protected]> Changelog-Fixed: JSON-RPC: `datastore` handles escapes in `string` parameter correctly.
When doing some plugin related work, I discovered that the datastore API has two issues: - Error messages on startup of plugins init method when the datastore is still completely empty: "Parsing '{datastore:[0:': token has no index 0: []" - Data is escaped but not unwrapped again when sending and getting from the API. [ Removed xfail, it now passes! --RR ] Closes: ElementsProject#5990
1dd29ea
to
6992e42
Compare
Yes, thats much better. I din't see that this was caused by the commando plugin sending a u64 'string'. |
ACK 6992e42 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I like allowing the caller to handle the empty result case.
ACK 6992e42
@@ -310,17 +310,19 @@ void rpc_scan(struct plugin *plugin, | |||
const char *guide, | |||
...); | |||
|
|||
/* Helper to scan datastore: can only be used in init callback. * | |||
Returns false if field does not exist. * path is /-separated. Final | |||
arg is JSON_SCAN or JSON_SCAN_TAL. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wouldn't have thought a comment block could give me anxiety, but this one succeeded!
No description provided.