Skip to content

extract pup-owned helpers out of the generator-owned client.rs/util.rs#658

Merged
MintsInc merged 1 commit into
mainfrom
ulysse.mavrocordatos/AAWF-1384/extract-common-owned-helpers
Jul 20, 2026
Merged

extract pup-owned helpers out of the generator-owned client.rs/util.rs#658
MintsInc merged 1 commit into
mainfrom
ulysse.mavrocordatos/AAWF-1384/extract-common-owned-helpers

Conversation

@MintsInc

Copy link
Copy Markdown
Member

Context

openapi-transformer's pup generator treats client.rs and util.rs as fully generator-owned files, copied byte-for-byte from a bundled snapshot on every regeneration. Tracing what generated command modules actually reference from them (only make_api!/make_api_no_auth! and util::read_json_file) showed nearly everything else in both files was pup's own hand-written command logic that just happened to live there. That mismatch caused a real regression in pup#651: regenerating the client silently deleted an OAuth-exclusion table entry and a read_to_string helper, both added by #654 ("feat(events): add event posting") after the last snapshot sync.

Changes

Split both files along the generator/hand-written boundary, mirroring how main.rs/generated.rs already separate hand-written and generated code:

  • client.rs shrinks to exactly what make_api!/make_api_no_auth! need: BearerAuthMiddleware/UserAgentMiddleware, make_dd_config/make_dd_client, the two macros, UNSTABLE_OPS.
  • New src/raw_client.rs holds everything else: HttpError/HttpResponse, AuthType/get_auth_type, the OAuth-exclusion table + apply_auth, parse_response_json, and all raw_* HTTP helpers — the "raw/generic Datadog HTTP client" subsystem used by ~16 command files for endpoints not covered by the typed SDK.
  • util.rs shrinks to just read_json_file. New src/util_ext.rs holds everything else: time/duration parsing, the monitor-diff helpers, parse_compute_raw, percent_encode.
  • This is a pure move — identical function bodies/signatures, only import paths changed across ~30 call sites. No behavior change.
  • Once this lands, these two files become safe for openapi-transformer to fully own without future feature work (like feat(events): add event posting #654) getting silently reverted on the next regeneration.

Tests

cargo build --all-targets, cargo test, cargo clippy --tests -- -D warnings, cargo fmt --check all pass. cargo test shows 3 pre-existing failures (test_cases_timeline/test_dbm_samples_search_uses_documented_payload/test_monitors_diff_detects_changes/test_spans_metrics_list, one of which varies per run) — confirmed identical on unmodified main (a PUP_MOCK_SERVER env-var race across parallel test threads), unrelated to this change.

openapi-transformer's pup generator copies client.rs/util.rs byte-for-byte
from a bundled snapshot on every regeneration, but only make_api!/
make_api_no_auth! and util::read_json_file are actually generator-relevant.
Everything else was pup's own hand-written command logic that just happened
to live in those files, so a routine feature PR (#654, event posting) got
silently reverted the next time the client was regenerated (pup#651).

Split both files along the generator/hand-written boundary, mirroring how
main.rs/generated.rs already separate hand-written and generated code:

- client.rs keeps only what make_api!/make_api_no_auth! need:
  BearerAuthMiddleware/UserAgentMiddleware, make_dd_config/make_dd_client,
  the two macros, UNSTABLE_OPS.
- New raw_client.rs holds the rest: HttpError/HttpResponse, AuthType/
  get_auth_type, the OAuth-exclusion table + apply_auth, parse_response_json,
  and every raw_* HTTP helper used by ~16 hand-written commands for
  endpoints not covered by the typed SDK.
- util.rs keeps only read_json_file. New util_ext.rs holds time/duration
  parsing, the monitor-diff helpers, parse_compute_raw, and percent_encode.

Pure move: identical function bodies/signatures, only import paths changed.
@MintsInc
MintsInc marked this pull request as ready for review July 20, 2026 11:37
@MintsInc
MintsInc requested a review from a team as a code owner July 20, 2026 11:37
@MintsInc
MintsInc merged commit b4deb0f into main Jul 20, 2026
6 checks passed
@MintsInc
MintsInc deleted the ulysse.mavrocordatos/AAWF-1384/extract-common-owned-helpers branch July 20, 2026 11:39
rachelyangdog added a commit to rachelyangdog/pup that referenced this pull request Jul 20, 2026
main moved raw_get/raw_post/raw_put from client.rs into a new
raw_client module (DataDog#658). Update the catalog and session
commands to call through raw_client so the branch builds against
current main.

Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com>
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