Introspection endpoints must return readable, test-friendly data (no ciphertext, mixed encodings, internal keys)
Principle
/_fakecloud/* endpoints exist for tests and debugging. Every response field should be directly readable and assertable: plaintext bodies, structured JSON where the value is JSON, real field names instead of internal map keys, consistent camelCase. A test author should never need an extra hop (KMS decrypt, base64 decode, string splitting, guessing which encoding a field is in) to see what happened.
When the at-rest or wire form is itself worth asserting on (e.g. "was this encrypted?"), expose it as an additional field next to the readable one, never instead of it.
Reported via #2755.
Findings
1. GET /_fakecloud/sqs/messages -> body is KMS ciphertext (#2755)
SSE-SQS (SqsManagedSseEnabled=true) is the default, so every message on a default queue is stored as a base64 fakecloud-KMS envelope, and the handler (crates/fakecloud-server/src/main.rs, /_fakecloud/sqs/messages route) clones the at-rest msg.body as-is. There is no documented way to decode it. Our own SDK e2e tests work around this by creating queues with SqsManagedSseEnabled=false (see comment in sdks/java/src/test/java/dev/fakecloud/E2ETest.java, same in python/ts/go/php).
Fix:
body= decrypted plaintext (same pathReceiveMessageuses,decrypt_message_bodyincrates/fakecloud-sqs/src/service/messages.rs).- New
storedBody= at-rest form (ciphertext envelope when encrypted, equal tobodyotherwise). - Update
crates/fakecloud-e2e/tests/sqs_kms.rsto assert ciphertext onstoredBodyand plaintext onbody. - Drop the
SqsManagedSseEnabled=falseworkaround from all SDK e2e tests so they exercise the default queue.
2. GET /_fakecloud/ses/emails -> rawData has two encodings, raw sends have no readable body
SendRawEmail(v1,crates/fakecloud-ses/src/v1_helpers.rs) and v2SendEmailwithContent.Raw(crates/fakecloud-ses/src/service/sending.rs) store the caller's base64 MIME blob verbatim inraw_data.- SMTP-listener submissions (
crates/fakecloud-server/src/ses_smtp.rs) store plain MIME in the same field. - Raw sends leave
textBody/htmlBodyasNone; onlysubjectis parsed.
Same mixup causes real bugs beyond introspection:
- DKIM (
crates/fakecloud-ses/src/dkim.rs) signs whateverraw_dataholds, i.e. the base64 text for API raw sends. - The SMTP relay (
FAKECLOUD_SES_SMTP_RELAY,sending.rs) base64-decodesraw_data; for SMTP-submitted mail (plain MIME) the decode fails and it falls back to rebuilding from empty bodies.
Fix: decode once at ingest so raw_data is always plain MIME; parse text/html parts from raw MIME into textBody / htmlBody; fix DKIM and relay to use the plain MIME. Document the field.
3. GET /_fakecloud/elbv2/waf-counts -> keys are an internal composite
Map keys are "<webAclArn>|<ruleName>" (crates/fakecloud-elbv2/src/dataplane.rs). Docs (website/content/docs/reference/introspection.md) describe it as "per-target-group allow/block counters", which is wrong: it only counts Count-action rule matches.
Fix: return [{ webAclArn, ruleName, count }]; correct the docs.
4. GET /_fakecloud/cognito/webauthn-credentials -> internal key + snake_case
pool_user is the internal map key "{pool_id}:{username}" (crates/fakecloud-cognito/src/service/branding.rs, emitted in main.rs), and the whole response uses snake_case (account_id, credential_id, ...) unlike every other endpoint.
Fix: split into poolId + username; camelCase all keys.
5. JSON documents returned as escaped strings
These match AWS wire shapes, but a test has to JSON.parse before asserting:
/_fakecloud/lambda/invocationspayload/_fakecloud/events/historydetail,deliveries.*.payload/_fakecloud/stepfunctions/executions,/_fakecloud/stepfunctions/sync-executionsinput/output/_fakecloud/bedrock/invocationsinput(raw request body viafrom_utf8_lossy,crates/fakecloud-bedrock/src/invoke.rs) andoutput, whose shape is inconsistent: provider JSON for InvokeModel but concatenated plain text for streaming calls (crates/fakecloud-bedrock/src/service.rs).
Fix: return the value as structured JSON when it parses (falling back to the string when it does not), or add a parsed sibling field. Pick one convention and apply it to all of these. Make Bedrock output consistent across invoke and streaming.
6. GET /_fakecloud/apigatewayv2/requests -> non-UTF-8 body silently dropped
body becomes None for non-UTF-8 payloads (crates/fakecloud-apigatewayv2/src/service/waf.rs), indistinguishable from "no body".
Fix: add isBase64Encoded + base64 body for binary payloads (same convention as API Gateway's own Lambda proxy events).
7. Doc drift found during the sweep
introspection.md:/_fakecloud/lambda/invocationspromises "response, duration", which the endpoint does not return. Either return them or fix the doc.introspection.md:/_fakecloud/stepfunctions/executionsclaims "step history", which it does not include.
Already fine (no change)
Encoded fields that are binary by nature and documented: s3/object-lambda-responses bodyBase64, rds/s3-import body_b64, ses/identities/{name}/dkim-public-key and route53/zones/{id}/dnssec *_b64 key material. Kinesis data inside Lambda event payloads is base64 because real Lambda events carry it that way. SNS messages, Cognito confirmation codes/tokens, ECS logs/events, KMS usage are readable.
Scope per fix
Each fix ships server + all seven SDKs (Rust, Python, TypeScript, Go, PHP, Java, .NET) types/docs + website/content/docs/reference/introspection.md + service docs + tests (e2e proving the readable form, and the raw sibling where added).
Compatibility
Not breaking in practice: field types stay strings/objects, and the opaque values being replaced were not usable by callers (no documented decode path). The new raw fields are additive. Shape changes for waf-counts and webauthn-credentials are real shape changes, but those outputs were internal keys nobody could rely on meaningfully; call them out in the release notes.
Done across five PRs:
- #2762 SQS:
bodyis plaintext,storedBodycarries the at-rest form; SDK e2e tests use default SSE-SQS queues. - #2765 SES: raw sends stored as plain MIME,
textBody/htmlBodyparsed from it; DKIM and the SMTP relay use the plain MIME. - #2764
waf-counts->{counts: [{webAclArn, ruleName, count}]},webauthn-credentials->poolId+username, camelCase; API Gateway v2 binary bodies base64 withisBase64Encoded. - #2763 JSON documents (lambda, events, stepfunctions, bedrock) returned as structured values, falling back to the string when not JSON; Bedrock
outputconsistent across invoke and streaming; doc drift fixed. - #2767 (not in the original list): the Python SDK raised
TypeErroron any response field it did not declare, so the new fields above broke older Python SDKs. It now drops unknown keys like the other six SDKs.
Release notes: waf-counts / webauthn-credentials shapes changed, the #5 fields changed from string to JSON value, and Python SDK users must upgrade alongside the server (earlier Python SDK versions cannot parse the new fields).