Skip to content

String rejection errors lose the field name or the decoding reason #6312

Backlog

Description

@thepastaclaw

PastaClaw flagged this while reviewing #6242, where it was deferred to a follow-up instead of being fixed in that pull request. This issue tracks the follow-up.

String rejection errors lose the field name or the decoding reason (suggestion)

Impact: A Kotlin developer diagnosing rejected query text, token inputs, funding arguments, or persisted fields can get an error that does not identify the failing value or why it was rejected.

Where: packages/rs-unified-sdk-jni/src/queries.rs:58-78 at ecf7f4de5437:

fn opt_c_string(env: &mut JNIEnv, value: &JString) -> Result<Option<CString>, ()> {
if value.is_null() {
return Ok(None);
}
let s = match crate::support::read_jstring(env, value) {
Ok(s) => s,
Err(e) => {
let _ = env.exception_clear();
crate::support::throw_sdk_exception(env, 1, &format!("string argument {e}"));
return Err(());
}
};
match CString::new(s) {
Ok(c) => Ok(Some(c)),
Err(_) => {
crate::support::throw_sdk_exception(
env,
1,
"string argument contained an interior NUL",
);
Err(())

The new rejections stop the operation, but several adapters discard information needed to fix the input. queries.rs and tokens.rs report string argument even for calls with multiple text inputs; funding.rs names the field but drops the JStringError reason. The persistence field readers know the field name, but with_bridge_load turns the propagated decoder error into a generic callback failure. Carry the field and decoder reason into the argument error or restore diagnostic without logging the string itself.

Origin

Activity

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions