Repository navigation
fix: NEXT_PUBLIC_INDEXER_URL wrongly required, broke verify/send/request - #27
Merged
Merged
Conversation
lib/config.ts required NEXT_PUBLIC_INDEXER_URL, but @kinlock/sdk's own KinlockConfig.indexerUrl is typed optional: chain-only operations (verifyReceipt, getLock, release, refund, decline, createLock) don't need an indexer. Since no indexer is deployed yet (M2-18) and the env var genuinely isn't set, every publicConfig()/kinlockConfig() call threw before any RPC request was attempted. /verify's Check button made zero network requests as a result. next.config.ts's rewrites already treated a missing indexer URL as expected; this was an app-side validation bug, not a real product gap. Changed the field to z.url().optional() to match the SDK's own contract, and added a regression test.
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.
What and why
Owner reported
/send,/verify, and/request"not functioning" even after the previous hotfix (#26). That hotfix was correct but only treated a symptom; this is the actual root cause, one level deeper.lib/config.ts'sPublicConfigSchemarequiredNEXT_PUBLIC_INDEXER_URL. But@kinlock/sdk's ownKinlockConfigtypes it asindexerUrl?: string(optional), precisely because chain-only operations (verifyReceipt,getLock,release,refund,decline,createLock) don't need an indexer. Since no indexer is deployed yet (M2-18, stillTODO) and the env var genuinely isn't set in this Vercel project, everypublicConfig()/kinlockConfig()call threw before any RPC request was even attempted.next.config.ts's rewrites already handled this correctly (if (!indexer) return {...empty rewrites...}), so this was akinlock-app-only over-strict validation bug, not a real product or infrastructure gap.Confirmed with Playwright against production: clicking "Check" on
/verifymade zero network requests and always produced the generic error, becauseverifyReceipt→kinlockConfig()→loadPublicConfig()threw synchronously beforefetchwas ever called.Changes
lib/config.ts:NEXT_PUBLIC_INDEXER_URL: z.url()→z.url().optional().lib/config.test.ts: regression test asserting a missing indexer URL doesn't throw.No other file needed a change:
kinlockConfig()'sindexerUrlassignment andlib/indexer.ts'slistPayees()already handle a possibly-undefinedvalue correctly by type (TypeScript confirms this;tsc --noEmitis clean).Hard rules / invariants touched
None. This restores chain-is-truth behavior (hard rule 3): verify/release/refund/decline read chain state directly and were being blocked from doing so by an app-level config bug, not a chain or auth issue.
Tests
pnpm lint,pnpm typecheck,pnpm test(94/94, new test included),pnpm buildall green.Reproduced against the exact production condition (dev server with the real, indexer-less
.env.local) before and after:/verify's Check button made 0 RPC requests, generic error every time.soroban-testnet.stellar.org, correctly resolving "Not valid / No payment with this transaction and event number exists" for a made-up hash./sendand/requeststill correctly show "The list of payees can't be loaded right now" — that part is accurate (no indexer exists yet), not a bug, and is unchanged by this fix.Docs / ADR
None needed.
Roadmap
No row status change. Changelog entry added explaining the full diagnosis.
Assumptions and open questions
This unblocks every chain-only SDK call app-wide (not just
/verify):/locks/[id]refund,/claim/[id]release/decline, and/send's actualcreateLockonce a payee can be selected. The payee-list UI (/send,/request,/payee) is still correctly blocked untilM2-18(indexer deployment) ships; that's a real, separate, larger piece of infrastructure work (a database, a long-running service, hosting/secrets decisions) that needs the owner's input on hosting choice and isn't something to provision unilaterally.Deploying this to
kinlock-app.vercel.appviavercel --prodimmediately after merge, given production is currently broken for this.