Repository navigation
Add context.Context support to all API methods - #9
Merged
Merged
Conversation
- Add ctx as the first parameter to all service methods and client.HTTPClient.DoRequest, propagated via http.NewRequestWithContext - Detach shared singleflight requests from the caller's cancellation (DoChan + context.WithoutCancel) so that one caller canceling does not fail the flight for other waiters; the completed flight still populates the cache while the canceled caller returns immediately - MockClient honors a canceled context
- README: add ctx to all code examples, fix method names that no longer exist (GetInfo -> GetAllListedInfo etc.), document the cache cancellation semantics in the cache section - CLAUDE.md: drop sections derivable from the code (directory layout, test pattern details) and keep only guidance that changes behavior
The indices API returns null O/H/L for indices that are distributed with a closing price only (e.g. codes 0504, 6000, 6095, 6096, B507), which previously decoded to 0 and broke E2E validation. - Change Index.O/H/L to *float64 (nil when close-only); C stays float64 since every published record has a closing price - Validate OHLC in the E2E test only when present, and require O/H/L to be all present or all nil - GetIndices_HistoricalData now specifies a code since the API requires code or date, and fails loudly instead of swallowing errors
The v2 /fins/summary API returns empty strings for unset numeric
fields (e.g. dividend forecasts), not null. Float64String leaves the
value at zero for empty strings, so pointer fields decoded to a
non-nil pointer to 0 -- making "not set" indistinguishable from a
real 0.
- Switch RawStatement numeric fields from *types.Float64String to
types.Float64StringWithDash, which models absent (""), undetermined
("-") and present values correctly
- Guard Float64StringWithDash.UnmarshalJSON against JSON null, which
previously slipped through the float64 branch and recorded 0
- Add Float64StringWithDash.ToInt64Ptr for share-count fields
- Fix a unit test that asserted the buggy behavior (empty string -> 0)
The output path is intentionally provided by the CLI user, so path traversal does not apply. G703 is a new rule in recent gosec versions and started failing CI without any code change.
This was referenced Jul 18, 2026
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
概要
全APIメソッドの第一引数に
context.Contextを追加し、呼び出し単位でのキャンセル・タイムアウト制御を可能にする。あわせて、E2Eテストで発覚した終値のみ配信指数の null 四本値問題を修正する。変更内容
context.Context 対応(破壊的変更)
client.HTTPClient.DoRequestの第一引数にctx context.Contextを追加http.NewRequestWithContextによりキャンセル・deadline を HTTP リクエストまで伝播(ページネーションループの途中でも即座に効く)sf.DoChan+context.WithoutCancelに変更:待機中の呼び出し元が1つキャンセルしても他の待機者は巻き込まれず、進行中のリクエストは完走してキャッシュに保存される。キャンセルした呼び出し元だけが即座にcontext.Canceledで戻るMockClientもキャンセル済み ctx を尊重context.Background()を追加するだけ終値のみ配信指数の null 四本値対応(破壊的変更)
float64のため 0 に化けていたIndex.O/H/Lを*float64に変更(Cはレコードが存在する以上必ず値があるためfloat64のまま)GetIndices_HistoricalDataは API 仕様(code または date が必須)に合わせて code を指定し、エラーを握りつぶさないよう変更ドキュメント
財務情報の空文字→0化けの修正(4コミット目で追加)
/fins/summaryは未設定の数値フィールドを null ではなく空文字で返すが、*types.Float64String経由では「非nilポインタで値0」にデコードされ、「非開示」と「0円」が区別できなかったRawStatementの数値フィールドをtypes.Float64StringWithDash(空文字・-・null をすべて nil として扱える)に切替Float64StringWithDashの JSON null が&0になる欠陥も修正し、回帰テストを追加テスト
TestClient_DoRequest_ContextCancellationを追加(-race付きで確認済み)TestIndicesService_GetIndices_CloseOnlyIndexを追加make test-e2e-v: 実APIに対して全テストパス