Skip to content

schema change for custom endpoints#6

Merged
airen1986 merged 2 commits intomainfrom
feature/pr-setup
Mar 11, 2026
Merged

schema change for custom endpoints#6
airen1986 merged 2 commits intomainfrom
feature/pr-setup

Conversation

@airen1986
Copy link
Owner

@airen1986 airen1986 commented Mar 11, 2026

Summary by CodeRabbit

  • New Features

    • Configurable authentication type for custom text-to-SQL endpoints (supports Bearer or custom header).
    • "Auth Type" input in Settings to specify and persist authentication for custom SQL generation.
    • Custom provider requests now include temperature, updated messaging, and use the final prompt structure for improved SQL output.
  • Chores

    • Updated internal module import path for SQLite worker.

@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: 095f37f6-f74c-445d-a6ba-98e4d3b596e1

📥 Commits

Reviewing files that changed from the base of the PR and between 2d0f0d1 and ed87b25.

📒 Files selected for processing (1)
  • src/common/js/scl-app.js
🚧 Files skipped from review as they are similar to previous changes (1)
  • src/common/js/scl-app.js

📝 Walkthrough

Walkthrough

Adds configurable auth type support for custom text-to-SQL providers (UI input, settings resolver, and request header construction), changes custom provider request payload to use finalPrompt and enhanced system messages, and updates a sqlite-wasm import path.

Changes

Cohort / File(s) Summary
Auth feature & request flow
src/common/js/scl-app.js, src/index.html
Adds TEXT_TO_SQL_CUSTOM_AUTH_TYPE_DEFAULT, new resolveCustomTextToSqlAuthType(settings), updates requestCustomSql() signature to accept authType and build headers dynamically, propagates custom-auth-type through UI/settings, and switches custom provider payloads to include finalPrompt, temperature, and system/user messages.
UI
src/index.html
Adds a new "Auth Type" text input (text-to-sql-custom-auth-type-input) under the Custom Endpoint settings group.
Worker import path
src/public/js/sqlite-worker.js
Changes sqlite-wasm module import from a sibling path to ../sqlite-wasm/index.mjs.

Sequence Diagram(s)

sequenceDiagram
  participant UI as UI (Settings / Prompt)
  participant App as scl-app.js
  participant Provider as Custom Provider (HTTP)
  participant DB as sqlite-worker

  UI->>App: user sets custom-auth-type & triggers SQL generation
  App->>App: resolveCustomTextToSqlAuthType(settings)
  App->>Provider: POST with headers (based on authType) and messages (system, user, finalPrompt)
  Provider-->>App: SQL response
  App->>DB: (optional) use sqlite-worker for local processing
  App-->>UI: display generated SQL
Loading

Estimated code review effort

🎯 3 (Moderate) | ⏱️ ~20 minutes

Poem

🐰 New headers hop into place with cheer,
A prompt refined, now clearer and near,
"Bearer" or custom, the rabbit does say,
Settings guide requests along their new way,
Hooray for tidy SQL paths today!

🚥 Pre-merge checks | ✅ 1 | ❌ 2

❌ Failed checks (1 warning, 1 inconclusive)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 10.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 'schema change for custom endpoints' is vague and doesn't accurately capture the main changes, which involve adding configurable authentication type support and updating request payloads for custom providers. Revise the title to be more specific, such as 'Add configurable auth type support for custom text-to-SQL providers' to better reflect the primary changes in the pull request.
✅ 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 (stacked PR)
  • 📝 Generate docstrings (commit on current branch)
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch feature/pr-setup

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

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: 2

Caution

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

⚠️ Outside diff range comments (1)
src/common/js/scl-app.js (1)

674-706: ⚠️ Potential issue | 🟠 Major

Handle chat-completions responses in the custom-provider path.

This request now sends an OpenAI-style messages payload, but the downstream extractor still ignores choices[0].message.content. With an OpenAI-compatible custom endpoint, successful responses will be treated as empty SQL and generateSqlFromPrompt() will fail.

🧩 Suggested follow-up in extractGeneratedSql()
 function extractGeneratedSql(response) {
   if (!response) return '';
   if (typeof response === 'string') return response.trim();
+  const chatContent = response?.choices?.[0]?.message?.content;
+  if (typeof chatContent === 'string') return chatContent.trim();
   if (typeof response.sql === 'string') return response.sql.trim();
   if (typeof response.query === 'string') return response.query.trim();
   if (response.data && typeof response.data.sql === 'string') return response.data.sql.trim();
   return '';
 }

Also applies to: 740-748

🤖 Prompt for all review comments with AI agents
Verify each finding against the current code and only fix it if needed.

Inline comments:
In `@src/common/js/scl-app.js`:
- Around line 570-575: The function resolveCustomTextToSqlAuthType treats any
non-exact "Bearer" as a header name; change it to normalize case-insensitively
so that values like "bearer" or "BEARER" are mapped to the canonical "Bearer"
string, otherwise return the original trimmed value as the header name; apply
the same case-insensitive normalization to the other similar helper near lines
678-682 that determines the header name for custom SQL auth.
- Around line 651-658: The system prompt object currently added to the message
contents (the object with role: 'system' and parts containing the SQL generator
text) must be removed from the contents array and instead set on the top-level
request field system_instruction; locate where the Gemini request is built (the
code that constructs the contents array including the role: 'system' object) and
replace that behavior by extracting the parts text (e.g., parts[].text or join
multiple parts) and assigning it to system_instruction, ensuring the contents
array only contains user/assistant messages and that the system prompt is not
duplicated.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro

Run ID: fbf6b6c3-74e1-498e-9e1b-8ede45659ab4

📥 Commits

Reviewing files that changed from the base of the PR and between 11c0d83 and 2d0f0d1.

📒 Files selected for processing (3)
  • src/common/js/scl-app.js
  • src/index.html
  • src/public/js/sqlite-worker.js

@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

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.

CodeRabbit commands

These commands are invoked using PR/Issue comments.

  • @coderabbitai pause to pause the reviews on a PR.
  • @coderabbitai resume to resume the paused reviews.
  • @coderabbitai review to trigger an incremental review. This is useful when automatic reviews are disabled for the repository.
  • @coderabbitai full review to do a full review from scratch and review all the files again.
  • @coderabbitai summary to regenerate the summary of the PR.
  • @coderabbitai evaluate custom pre-merge check --instructions <custom-checks-instructions> --name <custom-checks-title> [--mode <error|warning>] to validate the custom pre-merge checks instructions. Defaults to error when --mode is omitted.
    • @coderabbitai ignore pre-merge checks to override pre-merge checks and get an approval on PR.
    • @coderabbitai run pre-merge checks to run pre-merge checks on the pull request.
  • @coderabbitai generate docstrings to generate docstrings for this PR.
  • @coderabbitai generate sequence diagram to generate a sequence diagram of the changes in this PR.
  • @coderabbitai generate unit tests to generate unit tests for this PR.
  • @coderabbitai resolve to resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai generate configuration to create a PR that adds the current resolved configuration as .coderabbit.yaml (or show it if already present).
  • @coderabbitai help to get help.

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.
  • You can also validate your configuration using the online YAML validator.
  • 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, support, documentation and community

  • Visit our status page to check the current availability of CodeRabbit.
  • Create a ticket on our support page for assistance with any issues or questions.
  • Visit our documentation site for detailed information on how to use CodeRabbit.
  • Join our Discord community to connect with other users and get help from the community.
  • Follow us on X/Twitter for updates and announcements.

@coderabbitai
Copy link

coderabbitai bot commented Mar 11, 2026

Note

Docstrings generation - SUCCESS
Generated docstrings for this pull request at #7

coderabbitai bot added a commit that referenced this pull request Mar 11, 2026
Docstrings generation was requested by @airen1986.

* #6 (comment)

The following files were modified:

* `src/common/js/scl-app.js`
@airen1986 airen1986 merged commit ebbb95d into main Mar 11, 2026
2 checks 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.

1 participant