+
Skip to content

Conversation

Angelmmiguel
Copy link
Contributor

@Angelmmiguel Angelmmiguel commented Oct 16, 2025

Add support for custom environment variable configuration in rover.json, enabling projects to inject additional environment variables into AI agent containers. This feature introduces two optional properties: envs for explicit environment variable definitions and passthroughs, and envsFile for loading variables from dotenv files.

The custom environment variables are merged with agent-specific defaults and passed to Docker containers during task execution.

It closes #225

Changes

  • Added envs and envsFile optional properties to ProjectConfigSchema with appropriate getters
  • Bumped project schema version from 1.0 to 1.1 to support new configuration fields
  • Created parseCustomEnvironmentVariables() utility function supporting both passthrough (ENV_NAME) and explicit value (ENV_NAME=VALUE) formats
  • Created loadEnvsFile() utility function with path traversal validation and dotenv file parsing
  • Modified startDockerExecution() in task command to load, parse, and merge custom environment variables with agent defaults
  • Added dotenv package as a dependency for parsing dotenv files

Notes

Custom environment variables are appended after agent defaults when passed to Docker. When the same variable appears multiple times, Docker uses the last occurrence, allowing custom variables to override agent defaults.

Path traversal protection ensures envsFile paths are validated to stay within the project root directory. Invalid paths and missing files are silently skipped to maintain backwards compatibility.

Demo

I updated the project rover.json file to:

{
  "version": "1.1",
  "languages": [
    "javascript"
  ],
  "packageManagers": [
    "npm"
  ],
  "taskManagers": [],
  "attribution": true,
  "envs": [
    "STARSHIP_SHELL",
    "CUSTOM_VAR=test"
  ],
  "envsFile": ".env.rover"
}

Inside the container:

$ docker exec -it rover-task-74-1 bash
d04ab61b998a:/workspace$ env
CUSTOM_VAR=test
STARSHIP_SHELL=bash
ANOTHER_TEST=bye
THIS_IS_A_TEST=hello
...

Co-Authored-By: Rover <noreply@endor.dev>
@Angelmmiguel Angelmmiguel self-assigned this Oct 16, 2025
@Angelmmiguel Angelmmiguel added this to the v1.2 milestone Oct 16, 2025
Copy link
Contributor

@ereslibre ereslibre left a comment

Choose a reason for hiding this comment

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

LGTM, great feature!

@Angelmmiguel Angelmmiguel merged commit 514d98d into main Oct 17, 2025
4 checks passed
@Angelmmiguel Angelmmiguel deleted the rover/task-72-V4j38BcRilny branch October 17, 2025 08:10
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.

Add custom environment variable configuration to rover.json

2 participants

点击 这是indexloc提供的php浏览器服务,不要输入任何密码和下载