fix: add response.ok checks before .json() in CandleChart.tsx
Added HTTP error checks before calling .json() in the three fetch functions (fetchCandles, fetchAnnotations, fetchAnnotationTypes) to prevent silent failures on non-2xx responses. Marks task 4.12 as complete in tasks.md. Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
parent
4436cd655f
commit
4c53ef7cae
2 changed files with 4 additions and 1 deletions
|
|
@ -37,7 +37,7 @@
|
||||||
- [x] 4.9 `[haiku]` Add `parseInt(value, 10)` with `isNaN()` guard to all routes parsing integer query params
|
- [x] 4.9 `[haiku]` Add `parseInt(value, 10)` with `isNaN()` guard to all routes parsing integer query params
|
||||||
- [x] 4.10 `[sonnet]` Add CSV injection protection (prefix `=+@-` cells with `'`) to all export routes
|
- [x] 4.10 `[sonnet]` Add CSV injection protection (prefix `=+@-` cells with `'`) to all export routes
|
||||||
- [x] 4.11 `[sonnet]` Add `response.ok` checks before `.json()` in `src/app/page.tsx` (lines 214, 230, 245, 257)
|
- [x] 4.11 `[sonnet]` Add `response.ok` checks before `.json()` in `src/app/page.tsx` (lines 214, 230, 245, 257)
|
||||||
- [ ] 4.12 `[sonnet]` Add `response.ok` checks before `.json()` in `src/components/CandleChart.tsx` (lines 163, 178, 192)
|
- [x] 4.12 `[sonnet]` Add `response.ok` checks before `.json()` in `src/components/CandleChart.tsx` (lines 163, 178, 192)
|
||||||
|
|
||||||
## 5. ML Service Hardening (Python)
|
## 5. ML Service Hardening (Python)
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -161,6 +161,7 @@ const CandleChart = forwardRef<CandleChartHandle, CandleChartProps>(
|
||||||
try {
|
try {
|
||||||
const url = activeChartId ? `/api/candles?chartId=${activeChartId}` : '/api/candles';
|
const url = activeChartId ? `/api/candles?chartId=${activeChartId}` : '/api/candles';
|
||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
|
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
setCandles(data);
|
setCandles(data);
|
||||||
setIsEmpty(data.length === 0);
|
setIsEmpty(data.length === 0);
|
||||||
|
|
@ -176,6 +177,7 @@ const CandleChart = forwardRef<CandleChartHandle, CandleChartProps>(
|
||||||
try {
|
try {
|
||||||
const url = activeChartId ? `/api/annotations?chartId=${activeChartId}` : '/api/annotations';
|
const url = activeChartId ? `/api/annotations?chartId=${activeChartId}` : '/api/annotations';
|
||||||
const response = await fetch(url);
|
const response = await fetch(url);
|
||||||
|
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
setAnnotations(data);
|
setAnnotations(data);
|
||||||
return data;
|
return data;
|
||||||
|
|
@ -189,6 +191,7 @@ const CandleChart = forwardRef<CandleChartHandle, CandleChartProps>(
|
||||||
const fetchAnnotationTypes = async () => {
|
const fetchAnnotationTypes = async () => {
|
||||||
try {
|
try {
|
||||||
const response = await fetch('/api/annotation-types');
|
const response = await fetch('/api/annotation-types');
|
||||||
|
if (!response.ok) throw new Error(`HTTP error! status: ${response.status}`);
|
||||||
const data = await response.json();
|
const data = await response.json();
|
||||||
setAnnotationTypes(data.filter((t: AnnotationType) => t.is_active));
|
setAnnotationTypes(data.filter((t: AnnotationType) => t.is_active));
|
||||||
return data;
|
return data;
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue