Skip to content

test: cover SSE malformed-line, httpx config, stdin/locale edge cases; devcontainer prek switch#52

Merged
min0625 merged 1 commit into
mainfrom
test/coverage-and-prek
Jul 1, 2026
Merged

test: cover SSE malformed-line, httpx config, stdin/locale edge cases; devcontainer prek switch#52
min0625 merged 1 commit into
mainfrom
test/coverage-and-prek

Conversation

@min0625

@min0625 min0625 commented Jul 1, 2026

Copy link
Copy Markdown
Owner

Summary

  • Add regression tests ensuring a malformed SSE data: line (e.g. from a flaky proxy) is skipped rather than aborting the stream, across all three providers (anthropic, googlegenai, openai)
  • Add tests for internal/httpx's client construction (no overall timeout, TLS handshake timeout set, HTTP/2 forced, distinct client instances)
  • Add a stdin read-error regression test and two locale-fallback cases (LC_ALL=C / LC_ALL=POSIX falling through to LANG)
  • Swap pre-commit for prek in the devcontainer setup script and pin its version in mise.toml

Test plan

  • make test
  • make check (ran via pre-commit hook on this commit)

…ocale edge cases; switch devcontainer to prek

Adds regression coverage for provider streaming (malformed SSE data lines
must not abort the stream), the shared httpx client's timeout/transport
config, a stdin read-error path, and locale fallback when LC_ALL is C or
POSIX. Also swaps pre-commit for prek in the devcontainer setup.
@qodo-code-review

Copy link
Copy Markdown

Qodo is busy working

Check back in a few minutes. Qodo's code review agents are on it.

Grey Divider

@qodo-code-review

Copy link
Copy Markdown

PR Summary by Qodo

Add regression tests for SSE/stdio/httpx edge cases; switch devcontainer to prek

🧪 Tests ⚙️ Configuration changes 🕐 20-40 Minutes

Grey Divider

AI Description

• Add regression coverage for malformed SSE data: lines across all providers.
• Assert shared httpx client configuration (no global timeout, bounded handshake, HTTP/2).
• Cover stdin read errors and locale fallback behavior; switch devcontainer hooks to prek.
Diagram

graph TD
  A["mint CLI"] --> B["stdin + locale"] --> C["provider Complete()"] --> D["SSE parse loop"] --> E["httpx.New()"] --> F["http.Transport"]
  G["devcontainer setup"] --> H["prek + mise pin"]
Loading
High-Level Assessment

The following are alternative approaches to this PR:

1. Shared SSE malformed-line test helper
  • ➕ Reduces duplication across anthropic/googlegenai/openai tests
  • ➕ Makes it easier to add new providers with identical regression coverage
  • ➖ Can obscure provider-specific SSE formats and termination semantics
  • ➖ May encourage over-generalization when providers diverge
2. Fuzz/property tests for SSE parsing
  • ➕ Better coverage for partial/truncated/malformed line permutations
  • ➕ May catch additional edge cases beyond the single known regression
  • ➖ More effort to stabilize and keep deterministic
  • ➖ Harder to debug when failures are minimized inputs

Recommendation: Current approach (explicit per-provider regression tests plus targeted unit tests for httpx and CLI edge cases) is the best fit for a known production class of failures: it keeps provider formats visible while ensuring the behavior contract (skip malformed data: line, continue streaming) is enforced. If duplication grows with more providers, consider extracting a small shared helper specifically for 'SSE stream with one bad line' scenarios.

Files changed (7) +161 / -2

Tests (5) +158 / -0
main_test.goAdd stdin read-error and locale-fallback regression tests +24/-0

Add stdin read-error and locale-fallback regression tests

• Extends language canonicalization coverage for non-2/4-length subtags. Adds locale selection cases where LC_ALL is 'C'/'POSIX' and should fall back to LANG, plus a regression test ensuring stdin read errors surface as errors.

cmd/mint/main_test.go

httpx_test.goTest shared HTTP client defaults and transport settings +47/-0

Test shared HTTP client defaults and transport settings

• Introduces unit tests asserting 'httpx.New()' returns a non-nil client with no overall timeout, a bounded TLS handshake timeout, and HTTP/2 attempt enabled. Also verifies each call returns a distinct client instance.

internal/httpx/httpx_test.go

anthropic_test.goRegression test: skip malformed SSE data line during streaming +31/-0

Regression test: skip malformed SSE data line during streaming

• Adds a streaming test where one 'data:' line is invalid JSON and must be skipped. Verifies well-formed chunks before/after still produce the expected output.

internal/provider/anthropic/anthropic_test.go

google_genai_test.goRegression test: tolerate malformed SSE data line +27/-0

Regression test: tolerate malformed SSE data line

• Adds a Google GenAI streaming test ensuring an invalid JSON 'data:' line does not abort the stream. Confirms output concatenation continues across the malformed event.

internal/provider/googlegenai/google_genai_test.go

openai_test.goRegression test: tolerate malformed SSE data line through [DONE] +29/-0

Regression test: tolerate malformed SSE data line through [DONE]

• Adds an OpenAI streaming test where an invalid JSON 'data:' line appears mid-stream and must be skipped. Confirms streaming completes successfully and output matches the concatenated deltas.

internal/provider/openai/openai_test.go

Other (2) +3 / -2
post_create.shSwitch devcontainer hook install from pre-commit to prek +2/-2

Switch devcontainer hook install from pre-commit to prek

• Replaces pre-commit installation and hook setup with 'prek install' during devcontainer post-create. Keeps the rest of the bootstrapping flow intact.

.devcontainer/post_create.sh

mise.tomlPin prek version for reproducible dev tooling +1/-0

Pin prek version for reproducible dev tooling

• Adds a pinned 'prek' version to mise tool configuration to match the updated devcontainer setup flow.

mise.toml

@codecov

codecov Bot commented Jul 1, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.

📢 Thoughts on this report? Let us know!

@min0625 min0625 merged commit 4806be7 into main Jul 1, 2026
6 checks passed
@min0625 min0625 deleted the test/coverage-and-prek branch July 1, 2026 08:24
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.

1 participant