Skip to content

Wave 2: redacted HTTP debug tracing, --fields recipe, and roadmap status update#76

Merged
erseco merged 1 commit into
mainfrom
wave2-http-tracing-and-docs
Jul 8, 2026
Merged

Wave 2: redacted HTTP debug tracing, --fields recipe, and roadmap status update#76
erseco merged 1 commit into
mainfrom
wave2-http-tracing-and-docs

Conversation

@erseco

@erseco erseco commented Jul 8, 2026

Copy link
Copy Markdown
Owner

Summary

Wave-2 slice of the roadmap (#65): completes roadmap Subtask 7 (redacted HTTP debug tracing in the centralized layer), adds the deferred --fields recipe, and updates the roadmap to reflect what has actually landed.

Linked issue

Closes #75 (part of #65).

Changes

  1. src/py_moodle/http.py + tests/unit/test_http.py — the centralized HTTP layer now traces every request at DEBUG on a py_moodle.http logger (child of the shared py_moodle logger, so the existing --debug flag surfaces it on stderr): HTTP <METHOD> <redacted-url> -> <status>, plus a line per retry attempt and on final failure. Only method / redacted URL / status are ever logged — never params, request/response bodies, or headers. URL query secrets are scrubbed via the existing _redact_url.
  2. docs/recipes.md — new --fields recipe (json/yaml/csv projection, field ordering, unknown-field error, empty-value behavior).
  3. docs/roadmap-plan.md — dated "Progress update" section mapping subtasks → status → PRs (the phased plan is left intact as the forward-looking design).
  4. docs/development.md — documents the new http-layer tracing in the --verbose/--debug diagnostics section.

TDD evidence

Added three tests first: trace-with-status, URL-secret-redaction, and DEBUG-only opt-in. Confirmed red before the http.py logging existed (stashing http.py → the trace assertions fail with no py_moodle.http records), green after. One assertion was corrected: urlencode percent-encodes the ***REDACTED*** marker, so the test asserts the surviving REDACTED word while still proving the raw sesskey/wstoken values never appear.

Commands run:

pytest tests/unit/test_http.py -k trace -q      # red (stashed impl) -> green
pytest tests/unit                                # all pass
black --check src tests && isort --check-only src tests && flake8   # clean

Backwards compatibility

Fully compatible. Tracing is silent unless DEBUG is enabled; no request behavior changes. Docs-only for the recipe/roadmap.

Notes for reviewers

  • Retry support (Subtask 9) and centralized timeouts (Subtask 8) were already implemented (in http.py/config.py); this PR only adds the missing tracing half of the reliability/observability slice, so it does not touch retry/timeout logic.
  • The redacted URL in traces shows percent-encoded markers (e.g. wstoken=%2A%2A%2AREDACTED%2A%2A%2A) — intentional and safe (no secret leak).

Completes the wave-2 slice of the roadmap (#65):

- Subtask 7 (redacted debug mode): the centralized HTTP layer now traces
  every request at DEBUG on a 'py_moodle.http' logger, surfaced by the
  existing --debug flag, as 'HTTP <METHOD> <redacted-url> -> <status>'
  (plus retry attempts and final failure). Only the method, the redacted
  URL, and the status are ever logged -- never params, bodies, or headers.
  Unit tests cover the trace, secret redaction, and DEBUG-only opt-in.
- docs/recipes.md: add a '--fields' recipe (the deferred wave-1 doc item).
- docs/roadmap-plan.md: add a dated progress-update section mapping which
  subtasks have actually landed, with PR references.
- docs/development.md: document the new http-layer tracing in the
  --verbose/--debug diagnostics section.

Closes #75.
@erseco erseco merged commit f634b6a into main Jul 8, 2026
13 checks passed
@erseco erseco deleted the wave2-http-tracing-and-docs branch July 8, 2026 01:54
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.

Add redacted HTTP debug tracing to the centralized http layer (Subtask 7)

1 participant