Skip to content

Conversation

@niteshbalusu11
Copy link
Member

@niteshbalusu11 niteshbalusu11 commented Dec 8, 2025

Config files are terrible for production deployments to cloud providers. env variables are just simpler and easy.
This also removes a lot of code and makes stuff easier.

@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @niteshbalusu11, I'm Gemini Code Assist1! I'm currently reviewing this pull request and will post my feedback shortly. In the meantime, here's a summary to help you and other reviewers quickly get up to speed!

This pull request significantly refactors the Noah server's configuration management by transitioning from TOML-based files to environment variables. This change aims to simplify deployment, especially in containerized environments, by leveraging standard environment variable practices. The update involves modifying how configuration is loaded, removing dynamic file-watching capabilities, and adjusting Docker-related files to align with the new approach.

Highlights

  • Configuration Method Change: The server and CLI applications now load their configuration from environment variables, prefixed with NOAH_, instead of using TOML configuration files. This simplifies deployment and aligns with modern containerization practices.
  • dotenvy Integration: The dotenvy crate has been added to enable loading environment variables from .env files, which significantly streamlines local development setup by providing a convenient way to manage configuration.
  • Removed TOML Dependency and Hot-Reloading: The toml crate and its associated parsing logic, along with the config_watcher module for hot-reloading configuration from files, have been removed. Configuration changes now require a server restart to take effect.
  • Docker and Docker Compose Updates: The Dockerfile and scripts/docker-compose.yml have been updated to reflect the new environment variable-based configuration. This includes removing explicit config file mounts and adding an .env.regtest file for Docker Compose.
Using Gemini Code Assist

The full guide for Gemini Code Assist can be found on our documentation page, here are some quick tips.

Invoking Gemini

You can request assistance from Gemini at any point by creating a comment using either /gemini <command> or @gemini-code-assist <command>. Below is a summary of the supported commands on the current page.

Feature Command Description
Code Review /gemini review Performs a code review for the current pull request in its current state.
Pull Request Summary /gemini summary Provides a summary of the current pull request in its current state.
Comment @gemini-code-assist Responds in comments when explicitly tagged, both in pull request comments and review comments.
Help /gemini help Displays a list of available commands.

Customization

To customize Gemini Code Assist for GitHub experience, repository maintainers can create a configuration file and/or provide a custom code review style guide (such as PEP-8 for Python) by creating and adding files to a .gemini/ folder in the base of the repository. Detailed instructions can be found here.

Limitations & Feedback

Gemini Code Assist may make mistakes. Please leave feedback on any instances where its feedback is incorrect or counter productive. You can react with 👍 and 👎 on @gemini-code-assist comments. If you're interested in giving your feedback about your experience with Gemini Code Assist for Github and other Google products, sign up here.

You can also get AI-powered code generation, chat, as well as code reviews directly in the IDE at no cost with the Gemini Code Assist IDE Extension.

Footnotes

  1. Review the Privacy Notices, Generative AI Prohibited Use Policy, Terms of Service, and learn how to configure Gemini Code Assist in GitHub here. Gemini can make mistakes, so double check it and use code with caution.

Copy link
Contributor

@gemini-code-assist gemini-code-assist bot left a comment

Choose a reason for hiding this comment

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

Code Review

This pull request refactors the configuration management to use environment variables instead of a TOML file, removing the hot-reloading capability. The changes are consistently applied across the server, CLI, and Docker setup. The new approach simplifies the configuration logic significantly.

I've provided a few suggestions to further improve the implementation:

  • Avoiding unsafe when configuring AWS credentials.
  • Simplifying the loading of .env files.
  • Improving the loading logic for required configuration variables.
  • Reducing code duplication between the server and CLI binaries by refactoring into a shared library.

Overall, this is a solid refactoring. Addressing these points will enhance the code's safety and maintainability.

Comment on lines 94 to 108
fn validate(&self) -> Result<()> {
if self.postgres_url.is_empty() {
anyhow::bail!("NOAH_POSTGRES_URL is required");
}
if self.expo_access_token.is_empty() {
anyhow::bail!("NOAH_EXPO_ACCESS_TOKEN is required");
}
if self.ark_server_url.is_empty() {
anyhow::bail!("NOAH_ARK_SERVER_URL is required");
}
if self.s3_bucket_name.is_empty() {
anyhow::bail!("NOAH_S3_BUCKET_NAME is required");
}
Ok(())
}
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

This validate function can be removed by changing how required environment variables are loaded. Instead of loading with unwrap_or_default() and then checking for emptiness here, you can load required variables in load() to fail fast if they are missing. This would be more direct and consistent with how server/src/bin/cli.rs handles its configuration.

For example, for postgres_url:

// In Config::load()
let postgres_url = std::env::var(format!("{}{}", ENV_PREFIX, "POSTGRES_URL"))
    .context("NOAH_POSTGRES_URL is required")?;

// ... then in the struct initialization
let config = Self {
    postgres_url,
    // ... other fields
}

You can apply this pattern to all required variables (NOAH_POSTGRES_URL, NOAH_EXPO_ACCESS_TOKEN, NOAH_ARK_SERVER_URL, NOAH_S3_BUCKET_NAME) and then remove the validate function and its call on line 88.

@niteshbalusu11 niteshbalusu11 changed the title Add support for env variables Add support for env variables and drop config.toml Dec 8, 2025
@niteshbalusu11 niteshbalusu11 merged commit 8b1e85a into master Dec 8, 2025
7 of 11 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.

2 participants