Skip to content

Move to RedisString - #394

Closed
gkorland wants to merge 7 commits into
masterfrom
feature-redisstring
Closed

gkorland wants to merge 7 commits into
masterfrom
feature-redisstring

Conversation

@gkorland

Copy link
Copy Markdown
Contributor

No description provided.

@gkorland
gkorland requested review from gavrie and oshadmi June 16, 2021 06:38
@gkorland
gkorland marked this pull request as ready for review June 21, 2021 17:10
Comment thread src/lib.rs
format = Format::from_str(args.next_string()?.as_str())?;
}
_ => break,
_ => break, // TODO shoudl return an error??

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

It probably should.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Before commit 89b8a95 there seems to have been an error report Err(RedisError::Str("ERR syntax error"))

Comment thread src/lib.rs

let mut items: Vec<Value> = args
.map(|json| serde_json::from_str(&json))
.map(|json| serde_json::from_str(&json.into_string_lossy()))

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Is a lossy conversion what we want here? I know the Redis way is not to return errors, but can't this cause silent data corruption in case the input is not valid UTF-8? JSON should always be valid UTF-8.

Comment thread src/lib.rs
format = Format::from_str(args.next_string()?.as_str())?;
}
_ => break,
_ => break, // TODO shoudl return an error??

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Before commit 89b8a95 there seems to have been an error report Err(RedisError::Str("ERR syntax error"))

Comment thread src/c_api.rs
path: *const c_char,
) -> Result<JSONApiKey<'a>, RedisError> {
let ctx = Context::new(ctx);
let path = unsafe { CStr::from_ptr(path).to_str().unwrap() };

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This line not from this PR, but still would like to raise that since it is also related to UFT-8 and lossy conversion vs. error handling mentioned in this comment
let path = unsafe { CStr::from_ptr(path).to_str().unwrap() };
This would panic if invalid UTF-8 is passed here.

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

Since c_api.rs currently has no error reporting capability, we should detect conversion failure and the caller should return null on failure (assuming invalid UFT-8 can arrive from redis/from callers of new_from_str)

@gkorland gkorland closed this Jul 7, 2021
@gkorland
gkorland deleted the feature-redisstring branch July 8, 2021 06:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants