Skip to main content

to_json_value_redacted

Function to_json_value_redacted 

Source
pub fn to_json_value_redacted(
    graph: &SchemaGraph,
    ty: &SchemaType,
    value: &SchemaValue,
) -> Result<Value, RenderError>
Expand description

Render a value tree to a serde_json::Value, redacting every host-managed capability node (see HostManagedKind).

Each Secret / QuotaToken value — including those nested inside records, variants, lists, maps, options, results and unions — is replaced with the JSON string "<redacted: kind>". Non-capability material is encoded exactly as in to_json_value.

Use this on external-facing surfaces (MCP tool/resource responses, custom HTTP API responses) that would otherwise forward raw capability references to clients. Internal, trusted callers that need the lossless round-trippable form — registry storage, cross-worker RPC, oplog/grpc, config storage — should keep using to_json_value. Unlike to_json_value, the output of this function is not guaranteed to round-trip through from_json_value; the redacted placeholder is a one-way sink.