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

Response attributes with null/empty values #828

Open
ismellike opened this issue May 8, 2024 · 0 comments · May be fixed by #829
Open

Response attributes with null/empty values #828

ismellike opened this issue May 8, 2024 · 0 comments · May be fixed by #829

Comments

@ismellike
Copy link
Contributor

ismellike commented May 8, 2024

If a response's attribute value is set to the default string (null/empty), the WasmMsg will error out with an error like such:

Error {
    context: "Error executing WasmMsg:\n  sender: dao\n  Execute { contract_addr: \"contract0\", msg: {\"extension\":{\"msg\":{\"update_token_role\":{\"token_id\":\"1\",\"role\":null}}}}, funds: [] }",
    source: EmptyAttributeValue {
        key: "role",
    },
}

Example from cw721-roles with test:

.add_attribute("role", role.unwrap_or_default()))

app.execute_contract(
        Addr::unchecked(DAO),
        cw721_addr.clone(),
        &ExecuteMsg::Extension {
            msg: ExecuteExt::UpdateTokenRole {
                token_id: "1".to_string(),
                role: None,
            },
        },
        &[],
    )
    .unwrap_err();

Some cases like the proposal execute error logging cannot be defaulted, because it is set up to always contain an err. (should fix anyway though)

.add_attribute("error", msg.result.into_result().err().unwrap_or_default()))

ismellike added a commit to ismellike/dao-contracts that referenced this issue May 8, 2024
@ismellike ismellike linked a pull request May 8, 2024 that will close this issue
@ismellike ismellike changed the title Response attributes with unwrap_or_default() Response attributes with null/empty values May 8, 2024
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 a pull request may close this issue.

1 participant