fix(limits): guard missing limit-book orders on fresh deploy (#327) #803
No reviewers
Labels
No labels
agent:fix_bugfix
agent:fix_conflicts
agent:fix_security
agent:gap_analysis
agent:implement
agent:implement
agent:implement
agent:open_issues
agent:ready
agent:research
agent:security_audit
agent:verify
architecture
backend
blocker:hybrid
blocker:launch
blocker:limit-orders
blocker:v2
block:log_only
block:security
bug
ci
contracts
correctness
deploy
dev
devops
docs
documentation
duplicate
e2e
enhancement
epic
feature
frontend
functional-completion
gas
good first issue
governance
help wanted
high-risk
hooks
hybrid
indexer
infra
infrastructure
integrators
invalid
launch-blocker
limit-orders
localnet
localterra
low priority
missing-implementation
needs-design
ops
performance
priority
high
priority
medium
product
qa
QA
question
ready
ready
research
scripts
security
security-hardening
smartcontracts
tech-debt
testing
ux
UX
v2
verification
wontfix
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
code/cl8y-dex-terraclassic!803
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "cursor/gitlab-issue-workflow-35fc"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Summary
Fixes https://gitlab.com/PlasticDigits/cl8y-dex-terraclassic/-/work_items/327 —
/limitscould show rawCannot read properties of undefined (reading 'length')when switching pairs right after a fresh deploy while the indexer is still syncing.Root cause:
flatMap((p) => p.orders)treats a missingordersfield as a singleundefinedrow (the?? []fallback never runs). Downstream render/hint logic then throws. A secondary path wasgetAllPairsPaginatedreadingresp.pairs.lengthwhen LCD returned a body withoutpairs.Fix:
normalizeLimitBookPageResponseingetPairLimitBookPage(defaultsordersto[])flattenLimitBookPages/OrderBookPaneluse safe flatteninggetAllPairsPaginatedusesresp.pairs ?? []Cannot read properties of undefinedTypeErrorsPlaybook:
skills/AGENTS_FRONTEND_DEEP_ORDER_BOOK.mdrule #9.Acceptance checklist
npm run test -- --run src/components/trade/__tests__/OrderBookPanel.test.tsx src/pages/LimitOrdersPage.test.tsxorderson limit-book page treated as empty booknpm run test -- --run src/utils/__tests__/limitBookPagination.test.ts src/services/indexer/__tests__/client.test.tspairson factory LCD page does not throw in paginationnpm run test -- --run src/services/terraclassic/__tests__/factory.test.ts.lengthnpm run test -- --run src/utils/__tests__/humanizeUserFacingError.test.tsVerification for third parties
Manual (optional):
make setup-cloud-localterra,make dev, open/limits, switch pairs before indexer finishes initial sync — expect empty book or outage banner, not a crash.changed the description
mentioned in issue #327
Security review
Commit reviewed:
499e642c5a0670a1c4fda2f748ca8a09c39b51d4Scope: Defensive frontend hardening for missing
orders/pairsfields on limit-book and factory LCD responses, plus error-boundary humanization for raw TypeError messages (#327).Outcome:
FINDINGS: 0medium+Summary
Reviewed all added/modified production paths:
normalizeLimitBookPageResponse/flattenLimitBookPages/OrderBookPanel— safe coercion of missing or partial indexer pages to empty order lists; null entries filtered; no new attacker-controlled sinks (React text rendering via existing formatters; nodangerouslySetInnerHTML).getPairLimitBookPage— normalization applied at fetch boundary;pairAddrstill routed to configured indexer base URL only (unchanged SSRF surface).getAllPairsPaginated—resp.pairs ?? []prevents throw on malformed LCD page; pagination loop terminates cleanly on empty page (no DoS loop).sanitizeOpaqueErrorMessage— replaces runtime TypeError strings with generic copy; output remains React text nodes inErrorBoundary(no XSS vector).Indexer integrity / empty-book display: A hostile or stale indexer could already influence displayed book depth; this MR reduces crash surface and defaults to empty state rather than introducing new trust boundaries. Limit placement still relies on on-chain contract validation for
hint_after_order_id(unchanged).Inline threads: None — no medium+ findings to anchor.
Automated security review (MR webhook).
mentioned in commit
9d97e98108mentioned in commit
a40f5e351c