Skip to content

Fix OAuth redirect_uri truncation and bot API syntax errors - #114

Merged
github-actions[bot] merged 1 commit into
mainfrom
fix/oauth-redirect-uri-and-bot-api-errors
Oct 8, 2025
Merged

github-actions[bot] merged 1 commit into
mainfrom
fix/oauth-redirect-uri-and-bot-api-errors

Conversation

@ishaileshpant

Copy link
Copy Markdown
Collaborator

🔧 Fix Critical OAuth and Bot API Issues

Problem

The previous PR #112 introduced two critical issues that broke the main branch:

  1. OAuth redirect_uri truncation - Users getting "redirect_uri is not associated with this application" error
  2. Bot API 500 errors - Content submission failing with "A server e... is not valid JSON" error

Root Causes

  1. OAuth URL construction was using string concatenation instead of proper URL encoding
  2. Bot API syntax errors with duplicate try-catch blocks causing server crashes

Solution

  • Fixed OAuth redirect_uri using URLSearchParams for proper encoding
  • Removed duplicate try-catch blocks in bot API
  • Added debugging logs for OAuth URL construction
  • Fixed syntax errors that caused 500 responses

Technical Changes

// Before (causing truncation)
const authUrl = `https://github.com/login/oauth/authorize?` +
    `client_id=${this.clientId}&` +
    `scope=${this.scope}&` +
    `state=${this.generateState()}&` +
    `redirect_uri=${encodeURIComponent(redirectUri)}`;

// After (proper encoding)
const params = new URLSearchParams({
    client_id: this.clientId,
    scope: this.scope,
    state: state,
    redirect_uri: redirectUri
});
const authUrl = `https://github.com/login/oauth/authorize?${params.toString()}`;

Files Changed

  • github-auth.js - Fixed OAuth URL construction
  • api/github/create-content-pr.js - Fixed syntax errors

Impact

  • 🎯 Resolves OAuth authentication failures
  • 🎯 Fixes content submission bot API errors
  • 🚀 Restores full functionality to main branch
  • 🔍 Improves debugging with better logging

Testing

  • OAuth redirect_uri now properly encoded
  • Bot API syntax errors resolved
  • No linting errors
  • Proper error handling maintained

Branch naming: Follows convention with fix/ prefix

- Fix OAuth redirect_uri parameter using URLSearchParams for proper encoding
- Remove duplicate try-catch blocks in bot API that caused syntax errors
- Add debugging logs for OAuth URL construction
- Resolves 'redirect_uri is not associated with this application' error
- Fixes 500 Internal Server Error in content submission bot API

Issues fixed:
1. OAuth redirect_uri was being truncated due to improper URL construction
2. Bot API had syntax errors with duplicate catch blocks
3. Content submission was failing with 'A server e... is not valid JSON' error
@vercel

vercel Bot commented Oct 8, 2025

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for GitHub.

Project Deployment Preview Comments Updated (UTC)
prepguides-dev Ready Ready Preview Comment Oct 8, 2025 6:33pm

@ishaileshpant

Copy link
Copy Markdown
Collaborator Author

/approve

@github-actions
github-actions Bot merged commit 5bce30d into main Oct 8, 2025
11 checks passed
@github-actions

github-actions Bot commented Oct 8, 2025

Copy link
Copy Markdown
Contributor

🚀 Admin-Approved and Auto-Merged!

This PR has been automatically merged to main after admin approval by @ishaileshpant.

✅ **Status**: Merged and deployed
🔗 **Commit**: `5bce30dea18c94d3c1d0e3ccd8700ca4fa160406`
📅 **Merged at**: 2025-10-08T18:34:13.728Z
👤 **Approved by**: Admin/Maintainer/Owner

Thank you for your contribution! 🎉

@ishaileshpant
ishaileshpant deleted the fix/oauth-redirect-uri-and-bot-api-errors branch October 13, 2025 18:19
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