Skip to content

Comments

fix: serve runtime-config.json dynamically instead of writing to package directory#4600

Open
meadsteve wants to merge 1 commit intogoogle:mainfrom
meadsteve:fix/serve-runtime-config-dynamically
Open

fix: serve runtime-config.json dynamically instead of writing to package directory#4600
meadsteve wants to merge 1 commit intogoogle:mainfrom
meadsteve:fix/serve-runtime-config-dynamically

Conversation

@meadsteve
Copy link

@meadsteve meadsteve commented Feb 24, 2026

Fixes #4601

Summary

The dev UI frontend fetches runtime-config.json to discover the backendUrl (url_prefix). Previously, _setup_runtime_config wrote this file into the installed package directory (src/google/adk/cli/browser/assets/config/runtime-config.json) at startup. In containerized environments where .venv is read-only, this write fails silently (the IOError is caught and logged). The frontend then loads the static default {"backendUrl": ""} and makes API calls without the url_prefix, causing 404s.

This PR replaces the filesystem read/write with:

  • A pure _build_runtime_config() method that builds and returns the config dict
  • A dynamic GET /dev-ui/assets/config/runtime-config.json endpoint registered before the static mount so it takes priority

Test plan

  • Existing tests pass (pytest tests/unittests/cli/test_adk_web_server_run_live.py — 14 passed)
  • New unit tests for _build_runtime_config (default, with prefix, with logo, ValueError on partial logo config)
  • New integration test: GET /dev-ui/assets/config/runtime-config.json returns correct JSON via TestClient
  • Manual: adk web --url_prefix /foo and verify /dev-ui/assets/config/runtime-config.json returns {"backendUrl": "/foo"}

🤖 Generated with Claude Code

…age directory

The dev UI frontend fetches runtime-config.json to discover the backendUrl
(url_prefix). Previously this was written to the installed package directory
at startup, which fails silently in read-only environments (e.g. containerized
deployments with a read-only .venv). The frontend then falls back to the
default empty backendUrl, causing 404s for all API calls when url_prefix is set.

Replace the filesystem read/write with a pure builder method and serve the
config via a dynamic GET endpoint that takes priority over the static mount.

Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
@gemini-code-assist
Copy link
Contributor

Summary of Changes

Hello @meadsteve, 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 addresses a critical issue where the runtime-config.json file could not be written in read-only containerized environments, leading to incorrect backend URL configurations for the dev UI. By transitioning from a file-based configuration setup to a dynamic API endpoint, the system can now reliably provide the correct runtime configuration to the frontend, improving robustness and deployment flexibility without relying on mutable file systems.

Highlights

  • Dynamic Runtime Configuration: The runtime-config.json file is now served dynamically via a new FastAPI endpoint, eliminating direct file system writes at startup. This resolves issues in read-only containerized environments.
  • Refactored Configuration Logic: The logic for building the runtime configuration has been extracted into a new method, _build_runtime_config, which returns the configuration dictionary instead of handling file I/O.
  • New API Endpoint: A new GET endpoint, /dev-ui/assets/config/runtime-config.json, has been added to serve the dynamically generated runtime configuration to the frontend.
  • Enhanced Test Coverage: New unit tests were added for the _build_runtime_config method, covering various scenarios including URL prefixes and logo configurations. An integration test was also added for the new dynamic configuration endpoint.

🧠 New Feature in Public Preview: You can now enable Memory to help Gemini Code Assist learn from your team's feedback. This makes future code reviews more consistent and personalized to your project's style. Click here to enable Memory in your admin console.

Changelog
  • src/google/adk/cli/adk_web_server.py
    • Removed the _setup_runtime_config method, which previously handled reading and writing the runtime configuration to a file.
    • Introduced a new _build_runtime_config method to solely construct and return the runtime configuration dictionary.
    • Removed the call to the now-deleted _setup_runtime_config from the internal_lifespan method.
    • Added a new FastAPI GET endpoint /dev-ui/assets/config/runtime-config.json that dynamically serves the configuration generated by _build_runtime_config.
  • tests/unittests/cli/test_adk_web_server_run_live.py
    • Added a helper function _make_server to streamline the creation of AdkWebServer instances for testing.
    • Included a new test class TestBuildRuntimeConfig with unit tests for the _build_runtime_config method, covering default, prefixed, and logo configurations, as well as error handling for incomplete logo settings.
    • Added a new test class TestRuntimeConfigEndpoint to verify the functionality of the new dynamic /dev-ui/assets/config/runtime-config.json endpoint.
Activity
  • Existing tests passed (pytest tests/unittests/cli/test_adk_web_server_run_live.py — 14 passed).
  • New unit tests for _build_runtime_config were added, covering default, with prefix, with logo, and ValueError on partial logo config.
  • A new integration test was added to verify GET /dev-ui/assets/config/runtime-config.json returns correct JSON via TestClient.
  • Manual testing is planned to verify adk web --url_prefix /foo correctly returns {"backendUrl": "/foo"} from the dynamic endpoint.
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.

@google-cla
Copy link

google-cla bot commented Feb 24, 2026

Thanks for your pull request! It looks like this may be your first contribution to a Google open source project. Before we can look at your pull request, you'll need to sign a Contributor License Agreement (CLA).

View this failed invocation of the CLA check for more information.

For the most up to date status, view the checks section at the bottom of the pull request.

@adk-bot adk-bot added the web [Component] This issue will be transferred to adk-web label Feb 24, 2026
@adk-bot
Copy link
Collaborator

adk-bot commented Feb 24, 2026

Hello @meadsteve, thank you for your contribution!

Before we can review this PR, please sign the Contributor License Agreement (CLA).

Also, could you please create a GitHub issue for this bug fix and link it to this PR?

Finally, for bug fixes, could you please provide logs or a screenshot demonstrating the fix?

This information is required for us to proceed with the review. You can find more details in our contribution guidelines: https://github.com/google/adk-python/blob/main/CONTRIBUTING.md

Response from ADK Triaging Agent

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

The pull request successfully addresses the issue of serving runtime-config.json dynamically, which is a significant improvement for containerized environments where the package directory might be read-only. The implementation replaces filesystem operations with a dynamic FastAPI endpoint and includes thorough unit and integration tests. The code is clean and follows the existing patterns in the repository.

)
if web_assets_dir:
self._setup_runtime_config(web_assets_dir)
self._build_runtime_config()
Copy link
Contributor

Choose a reason for hiding this comment

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

medium

The call to _build_runtime_config() here is used for validation at startup, but its return value is ignored. While this correctly triggers a ValueError if the logo configuration is invalid, it might be confusing to other developers. Consider adding a brief comment to clarify that this call is for validation purposes.

@meadsteve
Copy link
Author

@adk-bot I've done what you've asked. How do I rerun the checks?

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

Labels

web [Component] This issue will be transferred to adk-web

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Dev UI returns 404s when url_prefix is set in read-only environments

2 participants