`/price/:assetA/:assetB/history` turns a bad `limit` into a 500 and an unknown pair into an empty 200
维护者通常 3 天内回复
@I-frenzy 已经在做这个了。
开始于 2026年11月20日。
评估
- 难度
- 2/5
- 预计耗时
- 1-3 小时
- 新手友好度
- 80/100
- Issue 类型
- 缺陷
- 描述清晰度
- 描述清楚
- 活跃度
- 活跃
- 技术栈
- openapi, postgresql, typescript
调研方向
先阅读 src/api/rest.ts 中的历史记录处理程序(第 305–376 行),然后检查 src/api/rest.ts 和 src/pagination.ts 中的 findPair 和 parseLimit。先查看 tests/rest-route.test.ts 和 src/__tests__/priceHistoryNetwork.test.ts 中的路由测试。更新 openapi.yaml 并重新生成生成的文件;无效限制返回 400、未监控的交易对返回 404、有效别名得到解析且现有响应结构得以保留时,即表示完成。
由索引模型根据 Issue 内容生成。
描述
Background
In src/api/rest.ts, the history handler parses limit like this (line 316):
const limit = Math.min(parseInt(req.query.limit ?? String(HISTORY_DEFAULT_LIMIT), 10), HISTORY_MAX_LIMIT)
?limit=abc gives NaN, and ?limit=-5 gives -5. Both are passed to Postgres as the LIMIT and the request fails with a 500. Every other paged route uses parseLimit from src/pagination.ts, which answers a non-number with a 400 and clamps the rest.
The same handler builds the pair key from the raw path (line 317, makePairKey(assetA, assetB)), while /price/:assetA/:assetB in the same file resolves the pair with findPair (line 222) and answers 404 unwatched_pair for a pair it does not watch. So /price/xlm/usdc/history, /price/native/USDC/history or a pair that does not exist all return 200 with an empty buckets list. An integrator cannot tell "no data yet" from "you spelled it wrong".
The window check also runs after the pair key and decimal work; it should be the first thing rejected.
What to build
- Parse
limitwithparseLimit; a non-integer is a 400 with codeinvalid_parameter. - Resolve the pair with
findPair, as the sibling routes do, and answer404 unwatched_pairwhen it is not watched on that network. Query with the resolvedpair.pairKey. - Keep the response shape and the gap declaration unchanged for a valid request.
- Update
openapi.yamlfor the 400 and 404 and regenerate the generated files.
Where to look
src/api/rest.tslines 305 to 376 andfindPairat line 50src/pagination.tsparseLimittests/rest-route.test.ts,src/__tests__/priceHistoryNetwork.test.ts
Done when
-
limit=abcreturns 400, andlimit=-5andlimit=999999are clamped; none reaches Postgres as an invalid value - An unwatched pair returns
404 unwatched_pair; a lower-case ornativespelling of a watched pair returns its data - A valid request returns the same body as before
- Generated files are regenerated and
npm testpasses
Drips Wave · Complexity: Easy · 100 points
Repo: Divinity-Labs/Lens. Install with npm ci, typecheck with npx tsc --noEmit, test with npm test. Tests are vitest. Do not run jest: it reports zero tests and proves nothing.
You cannot reach the production service. Prove your change with local tests and fixtures. Mock the database (pgPool, prisma) the way the existing tests in src/__tests__/ and tests/ do.
Generated files are checked byte for byte by CI. If you add or change a route, edit openapi.yaml by hand and then regenerate the generated files and commit them: npm run openapi:gen (writes openapi.json and the README sections), npm run client:gen (the TypeScript client schema) and, if you touched the GraphQL schema, npm run graphql:schema:gen (writes schema.graphql). The full list is in the scripts section of package.json; also read CONTRIBUTING.md. If a check fails and the diff looks empty, it is line endings: commit with LF.
Prices are high-precision decimals. Do not add a new place where a price or amount goes through parseFloat, Number() or ::float before it reaches the caller.
MCP tools must return exactly the fields the matching REST route returns (tests/mcp-lens.test.ts asserts equality), and the MCP tool modules must not import the database driver directly. Reads are injected.
Do not remove or loosen an existing API-key scope, CORS rule or rate limit, and do not replace src/app.ts wholesale. Past pull requests did both by accident.
Do not weaken a test to make it pass. No real user data, wallet addresses of real users, keys, tokens or connection strings in code, tests or fixtures. Never shorten a Stellar address or contract id; copy it in full from the file that defines it.
Required: Before submitting, join the contributor Telegram so your work can be tracked and counted toward the Stellar Wave: https://t.me/+fxHXq8f1SwlkZDBk
- 主要语言
- TypeScript
- 星标
- 4
- 派生
- 71
- 平均合并
- 2 天 6 小时
- 30 天内合并 PR
- 24
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 有 Pull Request 模板
- 阅读贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
Divinity-Labs/Lens 的其他 Issue
-
area:database difficulty:easy help wanted points:100 Stellar Wave
难度 2/5 1-3 小时 新手友好度 78/100
Divinity-Labs/Lens#688 · 1 条评论 ·
维护者通常 3 天内回复
-
area:reliability difficulty:easy help wanted points:100 Stellar Wave
难度 2/5 1-3 小时 新手友好度 72/100
Divinity-Labs/Lens#663 · 1 条评论 ·
维护者通常 3 天内回复
-
`/status?network=mainnet` is rate limited although `/status` is exempt可能已有人在做 @Joyful12-tech 于 1 天前认领。 未关闭area:reliability difficulty:easy help wanted points:100 Stellar Wave
难度 2/5 1-3 小时 新手友好度 84/100
Divinity-Labs/Lens#662 ·
维护者通常 3 天内回复
-
area:ingest difficulty:easy help wanted points:100 Stellar Wave
难度 2/5 1-3 小时 新手友好度 78/100
Divinity-Labs/Lens#633 ·
维护者通常 3 天内回复
-
Webhook retries have no jitter, so failures synchronise可能已有人在做 @Richard-tobi 于 35 天前认领。 未关闭area:reliability difficulty:easy help wanted points:100 Stellar Wave
难度 2/5 1-3 小时 新手友好度 80/100
Divinity-Labs/Lens#341 · 2 条评论 · 已指派 1 人 ·
维护者通常 3 天内回复
查看 Divinity-Labs/Lens 的全部 Issue
相似的 Issue
-
CLI OAuth login fails behind an authenticating proxy: GET /api/v1/user omits Proxy-Authorization未关闭
难度 1/5 1 小时以内 新手友好度 85/100
lightdash/lightdash#33086 · 1 条评论 ·
维护者通常 1 天内回复
-
[功能请求] 设置选项语言调整未关闭功能请求
难度 2/5 1-3 小时 新手友好度 66/100
维护者通常 1 天内回复
-
难度 2/5 1-3 小时 新手友好度 84/100
antithesishq/bombadil#473 ·
维护者通常 2 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 68/100
ardia-browser/ardia#3291 ·
维护者通常 1 天内回复
-
The structured output reference promises null results for refusals that carry validation details未关闭bug
难度 2/5 1-3 小时 新手友好度 72/100
维护者通常 1 天内回复