Skip to content

feat: Add environment variable support for AI agent configuration #2956

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 6 commits into
base: alpha
Choose a base branch
from

Conversation

andreafalzetti
Copy link

@andreafalzetti andreafalzetti commented Jul 30, 2025

Summary

Motivation

The AI agent feature currently only supports configuration through the JSON config file. This PR adds environment variable support to:

  • Enable easier deployment in containerized environments
  • Improve security by allowing API keys to be stored as environment variables
  • Maintain consistency with other dashboard configuration options

Implementation Details

Users can provide the complete agent configuration as a JSON string via the PARSE_DASHBOARD_AGENT_CONFIG environment variable:

PARSE_DASHBOARD_AGENT_CONFIG='{"models":[{"name":"ChatGPT 4.1","provider":"openai","model":"gpt-4.1","apiKey":"YOUR_API_KEY"}]}'

This supports the same multi-model configuration structure as the JSON config file, allowing users to define multiple AI models in the array.

Changes

  • Modified Parse-Dashboard/server.js to read agent configuration from PARSE_DASHBOARD_AGENT_CONFIG environment variable
  • Added support for both JS config objects and JSON strings in the configuration handling
  • Updated README.md with documentation for the new environment variable in the AI Agent configuration table
  • Added error handling for invalid JSON in PARSE_DASHBOARD_AGENT_CONFIG

Test plan

  • Tested full JSON configuration via PARSE_DASHBOARD_AGENT_CONFIG
  • Tested error handling for malformed JSON
  • Verified the configuration is properly passed to the agent endpoint
  • Tested with JS config object to ensure backward compatibility

🤖 Generated with Claude Code

Summary by CodeRabbit

  • New Features

    • Added support for configuring the AI agent via a new environment variable or CLI option, enabling flexible setup for single or multiple models.
  • Documentation

    • Updated documentation to include the new environment variable for AI agent configuration with detailed instructions for JSON-based multi-model setup.

This commit adds support for configuring the AI agent via environment variables,
following the same pattern used for other dashboard configurations.

Two configuration methods are supported:

1. Full JSON configuration via PARSE_DASHBOARD_AGENT_CONFIG
   - Allows complex multi-model setups
   - Accepts a JSON string with the complete agent configuration

2. Individual environment variables for simple single-model setups:
   - PARSE_DASHBOARD_AGENT_MODEL_NAME
   - PARSE_DASHBOARD_AGENT_MODEL_PROVIDER
   - PARSE_DASHBOARD_AGENT_MODEL
   - PARSE_DASHBOARD_AGENT_API_KEY

This enhancement makes it easier to deploy Parse Dashboard in containerized
environments and improves security by allowing API keys to be stored as
environment variables rather than in configuration files.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Copy link

parse-github-assistant bot commented Jul 30, 2025

🚀 Thanks for opening this pull request!

Copy link

coderabbitai bot commented Jul 30, 2025

📝 Walkthrough

Walkthrough

The change adds support for an agent parameter sourced from CLI options or the environment variable PARSE_DASHBOARD_AGENT_CONFIG in Parse Dashboard’s server. It parses this JSON string to configure the AI agent when CLI options are used. The README is updated to document this environment variable and how to configure multi-model AI agents via environment variables.

Changes

Cohort / File(s) Change Summary
Server agent config parsing
Parse-Dashboard/server.js
Adds support for an agent JSON string from CLI options or PARSE_DASHBOARD_AGENT_CONFIG environment variable. Parses and assigns it to the dashboard config or exits on parse error.
Documentation updates
README.md
Adds documentation for the new PARSE_DASHBOARD_AGENT_CONFIG environment variable, explaining how to configure AI agent models via JSON string in environment variables.

Estimated code review effort

🎯 1 (Trivial) | ⏱️ ~3 minutes

Note

⚡️ Unit Test Generation is now available in beta!

Learn more here, or try it out under "Finishing Touches" below.


📜 Recent review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 34d0f62 and d850603.

📒 Files selected for processing (1)
  • README.md (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • README.md

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.
    • Explain this complex logic.
    • 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. Examples:
    • @coderabbitai explain this code block.
    • @coderabbitai modularize this function.
  • 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 src/utils.ts and explain its main purpose.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.
    • @coderabbitai help me debug CodeRabbit configuration file.

Support

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

Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments.

CodeRabbit Commands (Invoked using PR 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 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 resolve all the CodeRabbit review comments.
  • @coderabbitai configuration to show the current CodeRabbit configuration for the repository.
  • @coderabbitai help to get help.

Other keywords and placeholders

  • Add @coderabbitai 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

Documentation and Community

  • 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.

@parseplatformorg
Copy link
Contributor

parseplatformorg commented Jul 30, 2025

🎉 Snyk checks have passed. No issues have been found so far.

security/snyk check is complete. No issues have been found. (View Details)

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

🧹 Nitpick comments (1)
README.md (1)

1313-1338: Excellent documentation with minor formatting improvement needed.

The AI agent environment variable documentation is comprehensive and well-structured. The two configuration methods are clearly explained with practical examples, and the precedence rules are clearly stated.

Consider adding language specification to the fenced code blocks for better syntax highlighting:

-```
+```bash
 PARSE_DASHBOARD_AGENT_CONFIG='{"models":[{"name":"ChatGPT 4.1","provider":"openai","model":"gpt-4.1","apiKey":"YOUR_API_KEY"}]}'

- +bash
PARSE_DASHBOARD_AGENT_MODEL_NAME="ChatGPT 4.1"
PARSE_DASHBOARD_AGENT_MODEL_PROVIDER="openai"
PARSE_DASHBOARD_AGENT_MODEL="gpt-4.1"
PARSE_DASHBOARD_AGENT_API_KEY="YOUR_API_KEY"

📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 192df4f and 4864ab7.

📒 Files selected for processing (2)
  • Parse-Dashboard/server.js (2 hunks)
  • README.md (2 hunks)
🧰 Additional context used
🧠 Learnings (1)
README.md (1)

Learnt from: mtrezza
PR: parse-community/parse-dashboard#0
File: :0-0
Timestamp: 2025-05-11T16:43:27.354Z
Learning: The bcryptjs library is used in Parse Dashboard for password encryption and validation in three files: Parse-Dashboard/Authentication.js (compareSync), Parse-Dashboard/CLI/mfa.js (genSaltSync, hashSync), and src/dashboard/Settings/DashboardSettings/DashboardSettings.react.js (genSaltSync, hashSync).

🪛 markdownlint-cli2 (0.17.2)
README.md

1321-1321: Fenced code blocks should have a language specified

(MD040, fenced-code-language)


1329-1329: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

🔇 Additional comments (3)
README.md (1)

216-221: Clear and comprehensive environment variable documentation.

The new AI agent environment variables are well-documented and follow the established documentation pattern. The variable names are descriptive and the comments provide helpful context for both simple and complex configuration approaches.

Parse-Dashboard/server.js (2)

42-46: LGTM! Consistent variable declarations.

The new agent configuration variables follow the established pattern and naming conventions. The precedence of CLI options over environment variables is correctly maintained.


91-108: Excellent implementation with proper error handling.

The agent configuration logic is well-implemented with several strong points:

  • Proper precedence: JSON config takes priority over individual variables
  • Robust error handling for JSON parsing with clear error messages
  • Validation that all required individual parameters are present
  • Clean object construction following the expected schema
  • Appropriate placement within the CLI configuration path

The implementation correctly matches the behavior documented in the README.

coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 30, 2025
The agent configuration is designed to support multiple models, so having
individual environment variables for a single model doesn't align with the
feature's multi-model design. This commit keeps only PARSE_DASHBOARD_AGENT_CONFIG
which accepts a JSON string with the full agent configuration.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
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: 1

🧹 Nitpick comments (1)
README.md (1)

1309-1320: Specify a language for the fenced code block and show the single-var example

markdownlint flags this snippet because the fenced block lacks a language identifier (MD040).
Adding bash (or env) improves readability and lint compliance, and you could append the individual-variable example for completeness.

-```
+```bash
 PARSE_DASHBOARD_AGENT_CONFIG='{"models":[{"name":"ChatGPT 4.1","provider":"openai","model":"gpt-4.1","apiKey":"YOUR_API_KEY"}]}'
 ```bash
+# Alternatively for a single-model setup:
+export PARSE_DASHBOARD_AGENT_MODEL_NAME="ChatGPT 4.1"
+export PARSE_DASHBOARD_AGENT_MODEL_PROVIDER="openai"
+export PARSE_DASHBOARD_AGENT_MODEL="gpt-4.1"
+export PARSE_DASHBOARD_AGENT_API_KEY="YOUR_API_KEY"
+```
📜 Review details

Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 4864ab7 and cc5ab7e.

📒 Files selected for processing (2)
  • Parse-Dashboard/server.js (2 hunks)
  • README.md (2 hunks)
🚧 Files skipped from review as they are similar to previous changes (1)
  • Parse-Dashboard/server.js
🧰 Additional context used
🧠 Learnings (1)
README.md (1)

Learnt from: mtrezza
PR: parse-community/parse-dashboard#0
File: :0-0
Timestamp: 2025-05-11T16:43:27.354Z
Learning: The bcryptjs library is used in Parse Dashboard for password encryption and validation in three files: Parse-Dashboard/Authentication.js (compareSync), Parse-Dashboard/CLI/mfa.js (genSaltSync, hashSync), and src/dashboard/Settings/DashboardSettings/DashboardSettings.react.js (genSaltSync, hashSync).

🪛 markdownlint-cli2 (0.17.2)
README.md

1315-1315: Fenced code blocks should have a language specified

(MD040, fenced-code-language)

// Add agent configuration from environment variables
if (configAgentConfig) {
try {
configFromCLI.data.agent = JSON.parse(configAgentConfig);
Copy link
Member

Choose a reason for hiding this comment

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

Does this work if it's not a JSON because it's set via JS config?

mtrezza and others added 2 commits July 31, 2025 08:42
- Change configAgentConfig to configAgent for naming consistency
- Handle both JS config objects and JSON strings properly
- Remove separate env var chapter, integrate into existing table
- Add environment variable column to AI Agent configuration table

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 31, 2025
- Remove the Environment Variable column from the AI Agent config table
- Keep environment variable information as a note below the table
- Properly align table columns for better readability

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
Adjust column widths for better visual consistency and readability.

🤖 Generated with [Claude Code](https://claude.ai/code)

Co-Authored-By: Claude <[email protected]>
coderabbitai[bot]
coderabbitai bot previously approved these changes Jul 31, 2025
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