Skip to content

Fix return types for some method #77

Description

@sirewix

Zitadel API is known to clash logical errors and transport errors, so for example, to return Ok(None) for when a user metadata not found in "get user metadata", we do this in v1 client:

// `QUERY-Rgh32` is the grpc message returned by Zitadel when no metadata was
// found for the given key
if let Err(status) = &response {
if status.code() == tonic::Code::NotFound && status.message().contains("QUERY-Rgh32") {
tracing::debug!("No user '{user_id}' metadata found for key '{key}'. Organization ID: {organization_id:?}");
return Ok(None);
}
}

None of the v2 client methods implement this handling logic. We need to go through the methods and implement similar type of logic where it can be useful.

{
  "code": 5,
  "message": "Metadata not found (QUERY-Rgh32)",
  "details": [
    {
      "@type": "type.googleapis.com/zitadel.v1.ErrorDetail",
      "id": "QUERY-Rgh32", // ideally we want to check this field instead of .message
      "message": "Metadata not found"
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or requesttech debtWork on this should be planned according to tech debt policy

    Fields

    No fields configured for Improvement.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions