Skip to content

Log the symbols Yahoo dropped from a batch quote request - #57

Open
werwolfby wants to merge 1 commit into
thorstenalpers:mainfrom
werwolfby:fix/warn-on-dropped-symbols
Open

Log the symbols Yahoo dropped from a batch quote request#57
werwolfby wants to merge 1 commit into
thorstenalpers:mainfrom
werwolfby:fix/warn-on-dropped-symbols

Conversation

@werwolfby

Copy link
Copy Markdown

A batch quote request returns only the symbols that resolved, with no indication that the others were dropped:

var r = (await yahoo.GetQuotesAsync(["AAPL", "BOGUSTICKER", "MSFT"])).ToList();
Console.WriteLine($"{r.Count} results: {string.Join(",", r.Select(x => x.Symbol))}");
// 2 results: AAPL,MSFT

No warning logged, no exception, nothing naming BOGUSTICKER. A consumer doing a scheduled refresh cannot tell "this ticker is invalid" from "this ticker was temporarily unavailable" without diffing the request against the response by hand.

Changes

GetQuotesAsync now diffs requested against returned symbols and logs a warning naming the ones Yahoo returned no data for. Matching ignores casing, since the request is lower-cased on the way out while Yahoo answers with canonical symbols. The returned collection is unchanged.

Scope, and what this deliberately does not do

It does not throw. The lenient behaviour is genuinely useful — it is exactly what lets a mixed batch survive one bad symbol (95 ms) where a solo bad symbol does not. Failing the whole batch because one ticker went stale would break every caller currently relying on partial results, and would be a worse default for the common case. The gap was never the leniency; it was that the omission was unobservable. A log warning closes that at zero compatibility cost.

It does not change the signature. The obvious alternative is returning a richer result type carrying per-symbol success and failure, but that would be new public API surface for information the caller already holds: they passed the symbol list in, and they get the resolved symbols back, so the shortfall is derivable from the response. Adding a type to carry a derivable value is not worth the API cost, and the existing shape stays the simple one.

So the change is intentionally the smallest thing that makes the behaviour visible: same return value, same exceptions, one warning.

Tests

Adds DroppedSymbolLoggingTests:

  • an unresolved symbol is named in a warning, and the resolved symbol still comes back
  • a fully resolved batch logs nothing
  • a symbol whose casing differs from Yahoo's is not reported as dropped

The last two are the ones that matter for false positives — a warning that fires on every successful call is worse than no warning at all.

TestCategory=Unit passes: 159 tests, 0 failures. No new analyzer warnings.

Note

Independent of #55 (cancellation) and #56 (no-data), and unlike those two it touches only GetQuotesAsync, so it should merge without conflicts in any order.


These changes were generated with Claude Code, and I have reviewed them.

🤖 Generated with Claude Code

GetQuotesAsync returns only the symbols that resolved, with no warning, no
exception and nothing naming the ones that did not. The leniency itself is
useful - it is what makes a mixed batch survive a bad ticker - but the
omission was unobservable, so a caller doing a scheduled refresh had to diff
requested against returned symbols by hand to find bad tickers.

Diff the request against the response and log a warning naming the symbols
Yahoo returned no data for. Matching ignores casing, since the request is
lower-cased on the way out and Yahoo answers with canonical symbols. The
returned collection is unchanged.
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