Skip to content

fix: conditionally show LLM API key - #4220

Draft
RichDom2185 wants to merge 5 commits into
masterfrom
minor-cleanup-20260801
Draft

fix: conditionally show LLM API key#4220
RichDom2185 wants to merge 5 commits into
masterfrom
minor-cleanup-20260801

Conversation

@RichDom2185

@RichDom2185 RichDom2185 commented Aug 1, 2026

Copy link
Copy Markdown
Member

Summary

  • A previously entered llmApiKey was being dispatched with the create-course payload even after the user toggled LLM grading off. Hiding the input was purely a UI concern.
  • DropdownCreateCourse.submitHandler now omits llmApiKey from the payload when enableLlmGrading is false.
  • Added DropdownCreateCourse.test.tsx covering:
    • Enter a key → disable grading → submit → key is absent from payload.
    • Enter a key while grading is enabled → submit → key is present.

Validation

  • yarn tsc -b clean
  • yarn eslint src/commons/dropdown/DropdownCreateCourse.{tsx,test.tsx} clean
  • yarn test — 91 files / 748 tests pass

@coderabbitai

coderabbitai Bot commented Aug 1, 2026

Copy link
Copy Markdown
Contributor

Review Change Stack

Important

Review skipped

Auto incremental reviews are disabled on this repository.

Please check the settings in the CodeRabbit UI or the .coderabbit.yaml file in this repository. To trigger a single review, invoke the @coderabbitai review command.

⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: 02341dd5-f8c9-4ed5-96b7-babdf6530a0b

You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.

Use the checkbox below for a quick retry:

  • 🔍 Trigger review
📝 Walkthrough

Summary by CodeRabbit

  • Bug Fixes
    • The LLM API key field now appears only when LLM grading is enabled.
    • The field remains optional and uses password masking for added privacy.

Walkthrough

The course creation form now displays the LLM API key field only when LLM grading is enabled. The field remains optional, uses password masking, and updates courseConfig.llmApiKey.

Changes

Course creation form

Layer / File(s) Summary
Conditional API key field
src/commons/dropdown/DropdownCreateCourse.tsx
The LLM API key input renders only when courseConfig.enableLlmGrading is enabled. Its optional password input and state update remain unchanged.

Estimated code review effort: 1 (Trivial) | ~3 minutes

🚥 Pre-merge checks | ✅ 5
✅ Passed checks (5 passed)
Check name Status Explanation
Docstring Coverage ✅ Passed No functions found in the changed files to evaluate docstring coverage. Skipping docstring coverage check.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
Title check ✅ Passed The title clearly identifies the main change: conditionally displaying the LLM API key based on LLM grading.
Description check ✅ Passed The description explains the payload fix and validation, but it omits the template's Type of change and Checklist sections.

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

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

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@src/commons/dropdown/DropdownCreateCourse.tsx`:
- Around line 263-282: Update the LLM grading toggle handling in
DropdownCreateCourse and the submitHandler payload so llmApiKey is cleared or
omitted whenever enableLlmGrading is false, preventing a previously entered key
from being dispatched. Add a test covering entering llmApiKey, disabling LLM
grading, and submitting the configuration.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Repository UI

Review profile: CHILL

Plan: Pro Plus

Run ID: d03c9c15-f097-497a-a7ae-e6eabb5d54f2

📥 Commits

Reviewing files that changed from the base of the PR and between d5f5f95 and 3b326fc.

📒 Files selected for processing (1)
  • src/commons/dropdown/DropdownCreateCourse.tsx

Comment on lines +263 to +282
{courseConfig.enableLlmGrading && (
<FormGroup
helperText="API Key for LLM endpoint. This key will be encrypted and will not be retrievable on the frontend after."
label={'LLM API Key'}
labelInfo="(optional)"
labelFor="llmApiKey"
>
<InputGroup
id="llmApiKey"
type="password"
value={courseConfig.llmApiKey}
onChange={e =>
setCourseConfig({
...courseConfig,
llmApiKey: e.target.value,
})
}
/>
</FormGroup>
)}

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🔒 Security & Privacy | 🟠 Major | ⚡ Quick win

Do not submit the API key when LLM grading is disabled.

After a user enters llmApiKey and disables LLM grading, the key remains in courseConfig. submitHandler dispatches the entire configuration, so hiding this input does not prevent the key from being submitted. Clear llmApiKey when disabling LLM grading, or omit it from the payload when enableLlmGrading is false. Add a test for this sequence.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@src/commons/dropdown/DropdownCreateCourse.tsx` around lines 263 - 282, Update
the LLM grading toggle handling in DropdownCreateCourse and the submitHandler
payload so llmApiKey is cleared or omitted whenever enableLlmGrading is false,
preventing a previously entered key from being dispatched. Add a test covering
entering llmApiKey, disabling LLM grading, and submitting the configuration.

@RichDom2185 RichDom2185 added the Bug Something isn't working label Aug 1, 2026
@RichDom2185
RichDom2185 marked this pull request as draft August 1, 2026 09:55
@coveralls

Copy link
Copy Markdown

Coverage Report for CI Build 30694647102

Coverage increased (+0.03%) to 44.738%

Details

  • Coverage increased (+0.03%) from the base build.
  • Patch coverage: 1 uncovered change across 1 file (10 of 11 lines covered, 90.91%).
  • No coverage regressions found.

Uncovered Changes

File Changed Covered %
src/commons/dropdown/DropdownCreateCourse.tsx 1 0 0.0%
Total (2 files) 11 10 90.91%

Coverage Regressions

No coverage regressions found.


Coverage Stats

Coverage Status
Relevant Lines: 14499
Covered Lines: 6958
Line Coverage: 47.99%
Relevant Branches: 7753
Covered Branches: 2997
Branch Coverage: 38.66%
Branches in Coverage %: Yes
Coverage Strength: 29.75 hits per line

💛 - Coveralls

@sayomaki

sayomaki commented Aug 9, 2026

Copy link
Copy Markdown
Contributor

I thought the plan we agreed on was just to remove the option to enable/disable from the create course dropdown? In that case course admins would still be able to enable it afterwards, and then add in the required API key.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants