fix(service_loader): stop silently swallowing credential/config parse errors - #84
Conversation
… errors load() used if-let-Ok on load_credentials/load_configuration, discarding any error the same way whether the file was simply absent (fine) or present but malformed (a real bug that should surface). Now only a missing-file io::ErrorKind::NotFound is swallowed; everything else propagates. Fixes #17
CI's fmt check flagged the previous commit's formatting.
…ogic collect_operations() hand-duplicated the same get/post/put/patch/delete/ head/options/trace block eight times; replaced with a loop over a verb-to-HttpMethodType table. service_writer::handle_path_items() had the mirror-image 8-arm match building the JSON path-item key; replaced with EnumFull's descriptor name (already used elsewhere in this file for InType), lowercased. Also folded the near-identical allOf/anyOf/oneOf branches in handle_schema() into one handle_composed_schema() helper. Added regression tests for handle_path_items (grouping by path/verb, rejecting an unset method) and handle_schema's composed-schema output. Fixes #6
|
The I don't have permission to re-run the failed job here ( Generated by Claude Code |
…flake Both connection-pooling tests sent two requests and asserted the second reused the first's pooled connection, but never read the first response's body. reqwest only returns a connection to its pool once the body is fully drained, so the assertion raced that release against the second request — observed failing in CI (#84) with an unrelated diff. Reading the body via .bytes() before the next request removes the race. Co-Authored-By: Claude Sonnet 5 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_018VzKriyNnMHmqQ6UxPhsv2
|
Update: found and fixed the actual race behind the flaky This is a one-off flaky-test fix, not part of the original scope (credential/config error handling + HTTP-verb dedup) — flagging it clearly as its own commit rather than folding it into the others. Generated by Claude Code |
Summary
ServiceLoader::load()usedif let Ok(x) = ...on the results ofload_credentials/load_configuration, which discarded any error identically — whether the file was simply absent (fine to skip) or present but malformed (a real bug that should surface).matchthat only swallowsServiceLoader::Iowhen itsio::ErrorKindisNotFound; every other error (malformed JSON, bad protobuf JSON, permission errors, etc.) now propagates via?, matching the discipline used everywhere else in this function.binary/apid/src/workers/loader.rs) already logsErrfromload(), so newly-surfaced errors get reported instead of vanishing — no caller changes needed.Fixes #17
Test plan
service_loader: missing credentials/config files are still skipped gracefully; malformed credentials now returnErr; malformed config now returnsErr.cargo test -p service_loader— 28/28 passing.git stash/popthat the new tests actually require the fix (they fail against the pre-fix code).cargo build --workspace --all-features— clean.Generated by Claude Code