Skip to content

Implement Inspect protocol for generated structs to redact PII fields#45

Open
claudio-dalicandro wants to merge 1 commit intomasterfrom
feat/inspect-protocol-pii
Open

Implement Inspect protocol for generated structs to redact PII fields#45
claudio-dalicandro wants to merge 1 commit intomasterfrom
feat/inspect-protocol-pii

Conversation

@claudio-dalicandro
Copy link
Copy Markdown

Problem

When generated Avro structs end up in logs (via Logger, IO.inspect/2, exception messages, etc.), PII-marked fields are displayed in plain text. This is a data privacy concern, IMHO.

Solution

For every record schema that has fields marked with "pii": true, the code generator now produces a defimpl Inspect that replaces PII field values with **REDACTED** in the inspect output. Records without PII fields are not affected — no custom Inspect implementation is generated.

Example

Given a schema with full_name and email marked as PII:

# Before (PII leaked in logs)
#=> %Events.V1.Person{id: "123", full_name: "John Doe", email: "john@example.com", age: 30}

# After (PII redacted)
#=> #PersonWithPii<[id: "123", full_name: "**REDACTED**", email: "**REDACTED**", age: 30]>

@claudio-dalicandro claudio-dalicandro requested a review from a team as a code owner April 28, 2026 15:28
@claudio-dalicandro claudio-dalicandro self-assigned this Apr 28, 2026
@claudio-dalicandro claudio-dalicandro force-pushed the feat/inspect-protocol-pii branch from 88394e1 to b6c2895 Compare April 28, 2026 15:33
…fields

Generate a custom defimpl Inspect for record modules that have PII-marked
fields. When inspected (e.g. in logs), PII field values are replaced with
**REDACTED** while non-PII fields are displayed normally.

Records without PII fields are unaffected — no Inspect impl is generated.
@claudio-dalicandro claudio-dalicandro force-pushed the feat/inspect-protocol-pii branch from b6c2895 to 6c190f3 Compare April 28, 2026 15:40
Copy link
Copy Markdown
Contributor

@cpiemontese cpiemontese left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If you update the CHANGELOG and run a suite-py bump I'll release after merge 😊

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 this pull request may close these issues.

2 participants