Repository navigation
Fix: Add production logging for StackOne utility tools - #24
Merged
Merged
Conversation
logger.error/warn were gated behind NODE_ENV=development, making all errors from getStackOneUtilityToolsForAISDK invisible in production. This caused silent failure when action tools (tool_search/tool_execute) failed to load, with no trace in Vercel runtime logs. - Make logger.error and logger.warn always log regardless of NODE_ENV - Add console.log/error at each step of the utility tools loading chain - Log full context (accountIds, integrations, API key presence) in chat route - Add hasActionTools check with RAG-only fallback system prompt Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
|
The latest updates on your projects. Learn more about Vercel for GitHub.
|
Contributor
There was a problem hiding this comment.
1 issue found across 4 files
Prompt for AI agents (unresolved issues)
Check if these issues are valid — if so, understand the root cause of each and fix them. If appropriate, use sub-agents to investigate and fix each issue separately.
<file name="apps/rag-knowledge-agent/src/app/api/chat/route.ts">
<violation number="1" location="apps/rag-knowledge-agent/src/app/api/chat/route.ts:141">
P2: Avoid logging account ID prefixes in production logs; this leaks identifiable integration/account data.</violation>
</file>
Reply with feedback, questions, or to request a fix. Tag @cubic-dev-ai to re-run a review.
| integrationIdsFromAgent: integrationIds.length, | ||
| integrationsFound: integrations.length, | ||
| accountIds: accountIds.length, | ||
| accountIdPreviews: accountIds.map(id => id.slice(0, 12) + '...'), |
Contributor
There was a problem hiding this comment.
P2: Avoid logging account ID prefixes in production logs; this leaks identifiable integration/account data.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At apps/rag-knowledge-agent/src/app/api/chat/route.ts, line 141:
<comment>Avoid logging account ID prefixes in production logs; this leaks identifiable integration/account data.</comment>
<file context>
@@ -134,10 +134,14 @@ export async function POST(request: NextRequest) {
+ integrationIdsFromAgent: integrationIds.length,
+ integrationsFound: integrations.length,
accountIds: accountIds.length,
+ accountIdPreviews: accountIds.map(id => id.slice(0, 12) + '...'),
+ documentIds: documentIds.length,
documentContext: documentContext.length,
</file context>
Suggested change
| accountIdPreviews: accountIds.map(id => id.slice(0, 12) + '...'), | |
| hasAccountIds: accountIds.length > 0, |
This branch was previously deployed
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.
Summary
logger.errorandlogger.warnwere gated behindNODE_ENV=development, silencing all errors in production Vercel deploymentsgetStackOneUtilityToolsForAISDK()failures were completely invisible — returning{}with no trace, causing the agent to only use RAG toolsconsole.log/console.errorat each step of the utility tool loading chain (fetchTools, utilityTools, getTool) so the exact failure point shows in Vercel runtime logshasActionToolscheck with a RAG-only fallback system prompt when action tools fail to loadTest plan
[Chat API],[Agent], and[StackOne tools]entries🤖 Generated with Claude Code
Summary by cubic
Fix silent production errors by enabling error/warn logging in prod and adding detailed runtime logs for StackOne tool loading. Adds a RAG-only fallback prompt when action tools aren’t available.
Bug Fixes
logger.errorandlogger.warnnow log in production (were gated byNODE_ENV=development).getStackOneUtilityToolsForAISDK()now surface instead of failing silently whentool_search/tool_executeare missing.New Features
fetchTools→utilityTools→getTool) and chat route context (account/integration counts,STACKONE_API_KEYpresence).hasActionToolscheck to switch to a RAG-only system prompt when action tools fail to load, with clear user messaging.Written for commit 48ca0f0. Summary will update on new commits.