Skip to content

fix(lading): surface remote-input parsing failures as errors#1903

Draft
goxberry wants to merge 1 commit into
goxberry/expect-fixme-user-configfrom
goxberry/expect-fixme-remote-input
Draft

fix(lading): surface remote-input parsing failures as errors#1903
goxberry wants to merge 1 commit into
goxberry/expect-fixme-user-configfrom
goxberry/expect-fixme-remote-input

Conversation

@goxberry
Copy link
Copy Markdown
Contributor

@goxberry goxberry commented May 23, 2026

Summary

Second PR in the FIXME-conversion stack. Addresses two sites where
malformed remote input — the Splunk HEC ack-id response and the
Prometheus scrape body — caused lading to crash.

generator/splunk_hec.rs::send_hec_request

Add Error::ResponseParse(#[from] serde_json::Error) and propagate
the JSON parse failure with ? instead of .expect(). Drop the
fn-level #[expect]. A malformed ack-id body is now a recoverable
generator error rather than a panic.

target_metrics/prometheus.rs::parse_prometheus_metrics

This is an ad-hoc Prometheus parser called for side effects from a
scrape loop. Returning a Result would require redesigning the
caller; the FIXME asked for recoverable errors, so we recover at
the line granularity: each former .expect() becomes a
let Some(...) else { warn!; continue; } (or a match for the
MetricType FromStr parse), so malformed lines are logged and
skipped rather than crashing the scraper. The two regex-capture
sites inside the label .map(|cap| ..) become .filter_map(|cap| ..)
with the same warn-and-skip pattern.

8 former .expect() sites in this function are now non-fatal log
points. The fn-level #[expect] is removed.

Test plan

  • ./ci/validate passes
  • grep -n 'FIXME' lading/src/generator/splunk_hec.rs lading/src/target_metrics/prometheus.rs is empty
  • cargo build --workspace --all-targets --all-features

🤖 Generated with Claude Code

The Splunk HEC ack-id parser and the ad-hoc Prometheus scrape parser
both panicked on malformed remote responses. Convert them to recover
without aborting the process.

splunk_hec::send_hec_request now adds Error::ResponseParse (from
serde_json::Error) and propagates parse failures with `?` instead of
`.expect()`. The fn-level FIXME `#[expect(clippy::expect_used)]` is
removed.

target_metrics::prometheus::parse_prometheus_metrics is called for
side effects from a scrape loop; redesigning the caller to take a
Result was out of scope. Each former `.expect()` is now a
`let Some(..) else { warn!; continue; }` (or `match` for the
MetricType `FromStr` parse) so malformed lines are logged and
skipped rather than crashing the scraper. The regex-capture sites
move from `.map(|c| c.expect(..))` to `.filter_map(|c| ..)` with the
same warn-and-skip pattern. The fn-level FIXME `#[expect]` is
removed.

Co-Authored-By: Claude Opus 4.7 <noreply@anthropic.com>
Copy link
Copy Markdown
Contributor Author

goxberry commented May 23, 2026

Warning

This pull request is not mergeable via GitHub because a downstack PR is open. Once all requirements are satisfied, merge this PR as a stack on Graphite.
Learn more

This stack of pull requests is managed by Graphite. Learn more about stacking.

@datadog-datadog-prod-us1
Copy link
Copy Markdown

Pipelines

Fix all issues with BitsAI

⚠️ Warnings

🚦 1 Pipeline job failed

Changelog Check | changelog-check   View in Datadog   GitHub Actions

🛟 This job is unlikely to succeed on retry. Please review your pipeline configuration. No changes to CHANGELOG.md detected. Add 'no-changelog' label if this is intentional.

Useful? React with 👍 / 👎

This comment will be updated automatically if new data arrives.
🔗 Commit SHA: 2224372 | Docs | Datadog PR Page | Give us feedback!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant