debug(meta-ads): add OAuth exchange logging for debugging#67
debug(meta-ads): add OAuth exchange logging for debugging#67JonasJesus42 wants to merge 1 commit intomainfrom
Conversation
🚀 Preview Deployments Ready!Your changes have been deployed to preview environments: 📦
|
There was a problem hiding this comment.
2 issues found across 1 file
Prompt for AI agents (all issues)
Check if these issues are valid — if so, understand the root cause of each and fix them.
<file name="meta-ads/server/main.ts">
<violation number="1" location="meta-ads/server/main.ts:102">
P1: Logging OAuth parameters exposes sensitive credentials (authorization code and code_verifier) to logs. Even for debugging, avoid logging the full `code` and `code_verifier` values as they could be captured in log aggregation systems.</violation>
<violation number="2" location="meta-ads/server/main.ts:134">
P1: Token URL redaction is incomplete - only `appSecret` is replaced, but the URL also contains the sensitive authorization `code` and `code_verifier` in query params. The comment "without secret" is misleading.</violation>
</file>
Reply to cubic to teach it or ask questions. Tag @cubic-dev-ai to re-run a review.
| { method: "GET" }, | ||
| const tokenUrl = `https://graph.facebook.com/${META_API_VERSION}/oauth/access_token?${params.toString()}`; | ||
| console.log( | ||
| "[Meta OAuth] Token URL (without secret):", |
There was a problem hiding this comment.
P1: Token URL redaction is incomplete - only appSecret is replaced, but the URL also contains the sensitive authorization code and code_verifier in query params. The comment "without secret" is misleading.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At meta-ads/server/main.ts, line 134:
<comment>Token URL redaction is incomplete - only `appSecret` is replaced, but the URL also contains the sensitive authorization `code` and `code_verifier` in query params. The comment "without secret" is misleading.</comment>
<file context>
@@ -122,16 +129,26 @@ const runtime = withRuntime<Env>({
- { method: "GET" },
+ const tokenUrl = `https://graph.facebook.com/${META_API_VERSION}/oauth/access_token?${params.toString()}`;
+ console.log(
+ "[Meta OAuth] Token URL (without secret):",
+ tokenUrl.replace(appSecret, "***"),
);
</file context>
| redirectUri?: string; | ||
| }) => { | ||
| console.log("[Meta OAuth] exchangeCode called"); | ||
| console.log("[Meta OAuth] oauthParams:", JSON.stringify(oauthParams)); |
There was a problem hiding this comment.
P1: Logging OAuth parameters exposes sensitive credentials (authorization code and code_verifier) to logs. Even for debugging, avoid logging the full code and code_verifier values as they could be captured in log aggregation systems.
Prompt for AI agents
Check if this issue is valid — if so, understand the root cause and fix it. At meta-ads/server/main.ts, line 102:
<comment>Logging OAuth parameters exposes sensitive credentials (authorization code and code_verifier) to logs. Even for debugging, avoid logging the full `code` and `code_verifier` values as they could be captured in log aggregation systems.</comment>
<file context>
@@ -98,7 +98,14 @@ const runtime = withRuntime<Env>({
redirectUri?: string;
}) => {
+ console.log("[Meta OAuth] exchangeCode called");
+ console.log("[Meta OAuth] oauthParams:", JSON.stringify(oauthParams));
+
const appSecret = getEnv("META_APP_SECRET");
</file context>
| console.log("[Meta OAuth] oauthParams:", JSON.stringify(oauthParams)); | |
| console.log("[Meta OAuth] oauthParams:", JSON.stringify({ | |
| ...oauthParams, | |
| code: oauthParams.code ? "[REDACTED]" : undefined, | |
| code_verifier: oauthParams.code_verifier ? "[REDACTED]" : undefined, | |
| })); |
Summary by cubic
Add detailed logging to the Meta Ads OAuth code exchange to make debugging easier. Logs incoming params, presence of META_APP_SECRET (without exposing it), masked token URL, and success/failure responses.
Written for commit a25112c. Summary will update automatically on new commits.