Skip to content

Comments

Log/vouch debug log#342

Open
madhurMongia wants to merge 3 commits intotestnetsfrom
log/vouch-debug-log
Open

Log/vouch debug log#342
madhurMongia wants to merge 3 commits intotestnetsfrom
log/vouch-debug-log

Conversation

@madhurMongia
Copy link
Contributor

@madhurMongia madhurMongia commented Feb 10, 2026

Summary by CodeRabbit

  • Bug Fixes

    • Enhanced chain validation with clearer error messages for unsupported chains
    • Improved error handling for batch transaction operations
  • Chores

    • Updated data endpoint for off-chain vouches retrieval

@netlify
Copy link

netlify bot commented Feb 10, 2026

Deploy Preview for proof-of-humanity-v2 ready!

Name Link
🔨 Latest commit 14a39f0
🔍 Latest deploy log https://app.netlify.com/projects/proof-of-humanity-v2/deploys/698b94dd73fe0f0008e03e0e
😎 Deploy Preview https://deploy-preview-342--proof-of-humanity-v2.netlify.app
📱 Preview on mobile
Toggle QR Code...

QR Code

Use your smartphone camera to open QR code link.

To edit notification comments on pull requests, go to your Netlify project configuration.

@coderabbitai
Copy link
Contributor

coderabbitai bot commented Feb 10, 2026

📝 Walkthrough

Walkthrough

The PR adds explicit chain validation with detailed error handling and logging to the vouch API route, introduces debug logging to the batch write hook for error tracking, and switches the off-chain vouches endpoint from an environment variable to a hardcoded testnet URL.

Changes

Cohort / File(s) Summary
API Route Chain Validation
src/app/api/vouch/[chain]/for-request/[claimer]/[pohid]/route.ts
Added explicit chain validation with unsupported chain error handling, enhanced debug logging for parameters and database queries, and catch-time error logging before 500 response.
Hook Debugging & Error Handling
src/contracts/hooks/useBatchWrite.ts
Added capabilities error logging, console output for capabilities and supportsBatchingTransaction, improved sendCalls error handling (sendError), expanded useCallsStatus with conditional query enablement, and useEffect hooks for logging call receipt and send errors.
Off-Chain Vouch Endpoint Configuration
src/data/request.ts
Switched getOffChainVouches endpoint from deployed app environment variable to hardcoded testnet URL with explanatory comment.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Suggested reviewers

  • kemuru

🐰 A rabbit hops through chains with care,
Validating every endpoint there,
With logs that shine and errors bright,
Testnet vouches see the light!

🚥 Pre-merge checks | ✅ 1 | ❌ 2
❌ Failed checks (1 warning, 1 inconclusive)
Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 0.00% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
Title check ❓ Inconclusive The title 'Log/vouch debug log' is vague and generic, using non-descriptive phrasing that doesn't clearly convey the main change. Use a more descriptive title that captures the primary change, such as 'Add debug logging to vouch API route and batch write hook' or 'Enhance vouch API observability with debug logs'.
✅ Passed checks (1 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch log/vouch-debug-log

Tip

Issue Planner is now in beta. Read the docs and try it out! Share your feedback on Discord.


Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Contributor

@coderabbitai coderabbitai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Fix all issues with AI agents
In `@src/data/request.ts`:
- Around line 163-167: The axios GET is using a hardcoded testnet URL which
risks hitting testnet from production; change the call in src/data/request.ts so
the base URL comes from a configurable constant or environment variable (e.g.,
POH_API_BASE or config.api.pohBase) instead of
`testnets--proof-of-humanity-v2.netlify.app`, and build the request URL from
that base with the same path segment
`/api/vouch/${chainId}/for-request/${claimer}/${pohId}`; ensure the code that
calls axios.get (the expression using chainId, claimer, pohId) falls back to a
clearly-documented testnet URL only if the env/config value is missing.
🧹 Nitpick comments (2)
src/app/api/vouch/[chain]/for-request/[claimer]/[pohid]/route.ts (1)

36-43: Debug logs: query params logged after execution; full response dumped.

Two observations:

  1. The DB query params (Lines 36-40) are logged after the query on Lines 29-34 has already executed. Move this log before the query for easier debugging of failures.
  2. Line 43 logs the entire data array. In a busy environment this can be very noisy and may inadvertently expose vouch details (signatures, expiration) in server logs.

Since this targets testnets, this is acceptable short-term, but consider guarding with a log-level check or removing before any production merge.

Suggested reorder
+    console.log("API Route DB Query Params:", {
+      chainId: chain.id,
+      pohId: params.pohid.toLowerCase(),
+      claimer: params.claimer.toLowerCase()
+    });
+
     const { data, error } = await datalake
       .from("poh-vouchdb")
       .select("*")
       .eq("chainId", chain.id)
       .eq("pohId", params.pohid.toLowerCase())
       .eq("claimer", params.claimer.toLowerCase());

-    console.log("API Route DB Query Params:", {
-      chainId: chain.id,
-      pohId: params.pohid.toLowerCase(),
-      claimer: params.claimer.toLowerCase()
-    });
-
-
-    console.log("vouches for request:", data);
+    console.log("vouches for request: count=", data?.length);
src/contracts/hooks/useBatchWrite.ts (1)

14-14: console.log on every render — move into a useEffect or remove.

Lines 14 and 22 execute unconditionally in the component body, so they fire on every re-render (including unrelated state changes from parent components). This adds noise to the console and has a minor perf cost from serializing capabilities each time.

Move to a useEffect
-  console.log("capabilities:", capabilities, capabilitiesError);
+  useEffect(() => {
+    console.log("capabilities:", capabilities, capabilitiesError);
+  }, [capabilities, capabilitiesError]);
   ...
-  console.log("supportsBatchingTransaction:", supportsBatchingTransaction);
+  useEffect(() => {
+    console.log("supportsBatchingTransaction:", supportsBatchingTransaction);
+  }, [supportsBatchingTransaction]);

Also applies to: 22-22

Comment on lines +163 to 167
//Prod endpoint not work need to debug it, using testnet endpoint for now, they both point to same DB in the backend
return (
await axios.get(
`${process.env.DEPLOYED_APP}/api/vouch/${chainId}/for-request/${claimer}/${pohId}`,
`https://testnets--proof-of-humanity-v2.netlify.app/api/vouch/${chainId}/for-request/${claimer}/${pohId}`,
)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Hardcoded testnet URL is a reliability and deployment risk.

Replacing the environment-variable-based endpoint with a hardcoded testnets--proof-of-humanity-v2.netlify.app URL means:

  • If this code path is ever reached from a production deployment (or merged to main), production users will silently hit a testnet endpoint.
  • The testnet Netlify deployment could go down or change independently of production, breaking vouching.

Even for the testnets branch, prefer an environment variable or at minimum a clearly-scoped constant so it doesn't silently propagate.

Suggested safer approach
-    //Prod endpoint not work need to debug it, using testnet endpoint for now, they both point to same DB in the backend
+    // TODO: Revert to env-based URL once prod endpoint issue is resolved
     return (
       await axios.get(
-        `https://testnets--proof-of-humanity-v2.netlify.app/api/vouch/${chainId}/for-request/${claimer}/${pohId}`,
+        `${process.env.NEXT_PUBLIC_VOUCH_API_URL ?? "https://testnets--proof-of-humanity-v2.netlify.app"}/api/vouch/${chainId}/for-request/${claimer}/${pohId}`,
       )
     ).data as { voucher: Address; expiration: number; signature: Hash }[];
🤖 Prompt for AI Agents
In `@src/data/request.ts` around lines 163 - 167, The axios GET is using a
hardcoded testnet URL which risks hitting testnet from production; change the
call in src/data/request.ts so the base URL comes from a configurable constant
or environment variable (e.g., POH_API_BASE or config.api.pohBase) instead of
`testnets--proof-of-humanity-v2.netlify.app`, and build the request URL from
that base with the same path segment
`/api/vouch/${chainId}/for-request/${claimer}/${pohId}`; ensure the code that
calls axios.get (the expression using chainId, claimer, pohId) falls back to a
clearly-documented testnet URL only if the env/config value is missing.

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