Repository navigation
Add explicit opt-in for sensitive NFC/OCR debug logging - #75
Conversation
Co-authored-by: s-jairl <253466913+s-jairl@users.noreply.github.com>
Co-authored-by: s-jairl <253466913+s-jairl@users.noreply.github.com>
Co-authored-by: s-jairl <253466913+s-jairl@users.noreply.github.com>
There was a problem hiding this comment.
🟡 Changes recommended
Error-level logging suppresses the required startup warning, and the test currently expects that suppression.
1 open finding
What changed in this PR
Adds an explicit development-only opt-in for sensitive NFC/OCR diagnostics while keeping ordinary debug logging PII-free.
Changes:
- Gates document logging on both debug level and
logging.include_pii, excluding portraits. - Adds startup warnings and operator guidance.
- Adds configuration and logging tests, including server tests in CI.
| File | Description |
|---|---|
| README.md | Documents opt-in usage and safeguards. |
| PRIVACY.md | Describes sensitive-log handling and retention. |
| Makefile | Includes server tests. |
| internal/config/config.go | Adds the PII logging toggle. |
| internal/config/config_test.go | Tests defaults and configuration precedence. |
| internal/apiv1/logging_test.go | Tests logging gates and portrait exclusion. |
| internal/apiv1/client.go | Adds gated diagnostics to both scan paths. |
| configs/config.yaml | Documents the disabled-by-default setting. |
| cmd/server/main.go | Adds the startup warning. |
| cmd/server/main_test.go | Tests warning behavior across log levels. |
| .github/workflows/ci.yml | Includes server tests in CI coverage. |
🧠 Review effort: Balanced
💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.
Co-authored-by: s-jairl <253466913+s-jairl@users.noreply.github.com>
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
jessevanmuijden
left a comment
There was a problem hiding this comment.
Approving: a careful, well-tested opt-in that keeps ordinary debug logging PII-free.
What I checked:
- Off by default.
include_piidefaults tofalse, andValidaterefuses it unlesslogging.levelisdebug. - Startup warning. It is logged whenever the toggle is on.
- What is logged. Only
DocumentData: names, dates, document number, nationality and MRZ lines. The portrait is replaced by its size, the caller's copy is left untouched, and chip data, FaceMaps and request bodies are never included. - Both scan paths.
/process-requestand/v1/id-scanboth log it, before the gates, so refused scans can be debugged too. - Checks.
go vetandgo test -race ./...pass locally, and CI is green.
Non-blocking notes:
- Stale docs: the README config row says the toggle "emits a startup warning even at higher log levels", and the PR description says "regardless of log level". Since "Require debug level for PII logging",
Validaterejectsinclude_piiat any level other thandebug, so both lines should say that instead. - #72: it adds debug logging of the same document data, and #74 exists because that conflicts with
PRIVACY.md. Once this merges, #72 should put its document-data logging behindinclude_pii(or reuselogDocumentData), or be closed if this covers what it needed.
Thanks for the review. @copilot : Address "non-blocking note" number 1. |
Co-authored-by: s-jairl <253466913+s-jairl@users.noreply.github.com>
Updated the README configuration row to state that |
|
False positive - triggers detection on old additions and is not picking up the main tests added in this change. |
|
Failed govulncheck is unrelated - will create a separate PR to address that. |



NFC/OCR troubleshooting sometimes requires document identity data, but ordinary debug logging must remain PII-free. This change separates development-only PII diagnostics from production-safe debug logging.
logging.include_pii/LOG_INCLUDE_PII, defaulting tofalse. Both scan paths log parsed document fields only when the toggle and debug logging are enabled.Development-only configuration: