Skip to content

api: 4xx JSON for historic queries, add robots.txt - #1313

Open
mikelberlin wants to merge 5 commits into
masterfrom
fix/api-historic-4xx
Open

mikelberlin wants to merge 5 commits into
masterfrom
fix/api-historic-4xx

Conversation

@mikelberlin

@mikelberlin mikelberlin commented Nov 9, 2026 •

Copy link
Copy Markdown

Fixes Search Console 5xx on historic API queries.

  • /v1/foreignQuotation/:source/:symbol?time= before data exists (history starts 2023-07-20): the handler passed a nil error to SendError (panic, 500). Now 404 JSON. Non-numeric time now 400.
  • Genuine backend failures (InfluxDB/database errors) keep 500, so monitoring still sees outages. 404 is returned only when there is no error and no data.
  • YahooFinance reversed pairs (EUR-USD read as USD-EUR) are unchanged: no history still returns 200 with zero values; a backend error returns 500.
  • /v1/assetUpdates/...?starttime=&endtime= with no quotations in range indexed an empty slice (panic, 500). Now 404 JSON. Bad numeric/time params and over-long ranges now 400.
  • GET /robots.txt on the API returns User-agent: * / Disallow: /. The API is JSON only, nothing depends on crawling.

Behaviour change to note

validateInputParams (path or query values containing special characters) now returns 400 instead of 500, on every endpoint that uses it. The error JSON shape is unchanged (errorcode, errormessage; errorcode now reads 400).

Tests

historic_test.go covers: backend error -> 500, empty data -> 404, bad params -> 400, Yahoo reversed no-history -> 200, and the original panic URLs for both endpoints. The assetUpdates cases need a throwaway Redis (REDISURL) and are skipped without it; the package init also needs Postgres with asset and blockchain tables. go vet and gofmt are clean.

🤖 Generated with Claude Code

mikelberlin and others added 2 commits November 9, 2026 11:52
…of 500

foreignQuotation with a time before data exists hit SendError with a nil error (panic, 500); assetUpdates indexed an empty quotation slice (panic, 500). Both now return 404, and malformed params return 400.

Co-Authored-By: Claude Opus 5.5 <[email protected]>
@mikelberlin
mikelberlin requested a review from a team as a code owner November 9, 2026 10:54
@mikelberlin

Copy link
Copy Markdown
Author

For reviewers: this PR turns panics on historic-param REST endpoints into 404/400 and keeps 500 for real backend errors. It also adds GET /robots.txt with Disallow: /.

The last commit bumps cmd/http/restServer to diadata v1.4.714, as #1309 did. PR Validation creates the v1.4.714 release. Merging to master then builds and deploys the REST server through Production Deployment.

🤖 Generated with Claude Code

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