Skip to content

Conversation

@samme-abdul
Copy link
Contributor

@samme-abdul samme-abdul commented Sep 2, 2025

📝 Description

Updated the OAuth configuration check to ensure 'oauth_con_id' is not undefined before proceeding. This prevents potential issues when 'oauth_con_id' is missing from the config data and makes the first check true if it is undefined

🔗 Related Issues

  • Fixes #
  • Relates to #

🔧 Type of Change

  • 🐛 Bug fix (non-breaking change that fixes an issue)
  • ✨ New feature (non-breaking change that adds functionality)
  • 📚 Documentation update
  • 🔧 Code refactoring (no functional changes)
  • 🧪 Test improvements
  • 🔨 Build/CI changes

✅ Checklist

  • Self-review performed
  • Tests added/updated
  • Documentation updated (if needed)

Summary by CodeRabbit

  • Bug Fixes

    • Resolved an issue where OAuth headers could be added without a valid connection ID, preventing unintended authentication and sporadic request failures.
    • Tightened OAuth activation logic to avoid false positives, improving reliability across API calls.
  • Improvements

    • Standardized how OAuth headers are appended to existing request headers, reducing edge-case conflicts.
    • Enhanced stability of authenticated requests, leading to more predictable behavior in integrations using OAuth.

Updated the OAuth configuration check to ensure 'oauth_con_id' is not undefined before proceeding. This prevents potential issues when 'oauth_con_id' is missing from the config data and makes the first check true if it is undefined
@coderabbitai
Copy link

coderabbitai bot commented Sep 2, 2025

Walkthrough

Tightened the OAuth activation condition by guarding against undefined oauth_con_id and changed how OAuth headers are appended to reqConfig.headers using concat instead of a spread-merge. No exported/public APIs were altered.

Changes

Cohort / File(s) Summary
OAuth header handling
packages/core/src/Components/APICall/APICall.class.ts
Added explicit undefined/empty/"None" guard for oauth_con_id before generating OAuth headers; updated header application from spread-merge to reqConfig.headers = reqConfig.headers.concat({ ...oauthHeaders }); retained existing oauthService logic otherwise.

Sequence Diagram(s)

sequenceDiagram
  autonumber
  actor Caller
  participant APICall
  participant OAuthService as OAuthService
  participant HTTP as HTTP Client

  Caller->>APICall: build request config
  alt oauthService present AND oauth_con_id defined/non-empty/non-"None"
    APICall->>OAuthService: getOAuthHeaders(oauth_con_id)
    OAuthService-->>APICall: oauthHeaders
    APICall->>APICall: reqConfig.headers = headers.concat(oauthHeaders)
  else No OAuth headers
    note over APICall: Skip OAuth header attachment
  end
  APICall->>HTTP: send(reqConfig)
  HTTP-->>APICall: response
  APICall-->>Caller: response
Loading

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

A hop, a skip, a guarded check—
No phantom IDs sneak on deck.
Headers now line up in rows,
Concat the carrots, off it goes.
With tidy paws and steady sight,
The call hops forth, precisely right. 🥕🐇

✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch fix/oauth-config-check

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore or @coderabbit ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

Copy link

@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: 0

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
packages/core/src/Components/APICall/APICall.class.ts (3)

118-123: Fix optional-chaining bug and make checks consistent for oauthService.

config.data.oauthService on the RHS uses no optional chaining; this can throw when config or config.data is undefined. Also add the missing undefined guard for oauthService to mirror oauth_con_id.

-                if ((config?.data?.oauth_con_id !== undefined && config?.data?.oauth_con_id !== '' && config?.data?.oauth_con_id !== 'None') || (config?.data?.oauthService !== '' && config.data.oauthService !== 'None')) {
+                if (
+                    (config?.data?.oauth_con_id !== undefined &&
+                     config?.data?.oauth_con_id !== '' &&
+                     config?.data?.oauth_con_id !== 'None') ||
+                    (config?.data?.oauthService !== undefined &&
+                     config?.data?.oauthService !== '' &&
+                     config?.data?.oauthService !== 'None')
+                ) {

100-101: Headers built with Array.concat: Axios expects an object, not an array.

reqConfig.headers must be a plain object or AxiosHeaders. Using .concat risks a runtime error (.concat is not a function) or malformed headers.

-            reqConfig.headers = (await parseHeaders(input, config, agent)).concat({ ...headers });
+            reqConfig.headers = {
+                ...(await parseHeaders(input, config, agent)),
+                ...(headers || {}),
+            };

121-123: Do not append OAuth headers with Array.concat; merge objects instead.

Same issue as above; merge into the existing headers object.

-                    //reqConfig.headers = { ...reqConfig.headers, ...oauthHeaders };
-                    reqConfig.headers = reqConfig.headers.concat({ ...oauthHeaders });
+                    reqConfig.headers = { ...(reqConfig.headers || {}), ...oauthHeaders };
🧹 Nitpick comments (1)
packages/core/src/Components/APICall/APICall.class.ts (1)

117-123: Optional: centralize “provided value” checks and normalize sentinel values.

Reduce repetition and avoid hard-coding 'None' checks everywhere.

Example (within process before the if):

const isProvided = (v?: string) => {
  const s = (v ?? '').trim();
  return s !== '' && s.toLowerCase() !== 'none';
};
if (isProvided(config?.data?.oauth_con_id) || isProvided(config?.data?.oauthService)) {
  // ...
}
📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

Cache: Disabled due to data retention organization setting

Knowledge Base: Disabled due to data retention organization setting

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between bbf6ca6 and 9a283c4.

📒 Files selected for processing (1)
  • packages/core/src/Components/APICall/APICall.class.ts (1 hunks)

@alaa-eddine-k alaa-eddine-k merged commit 1655c00 into dev Sep 2, 2025
1 check passed
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.

3 participants