fix: allow CORS wildcard for Rust server and refactor v1-config to helper template#128
Conversation
…lper template The CORS wildcard validation incorrectly rejected ["*"] for Chroma >= 1.0.0, but the Rust server supports it. Refactored v1-config generation into a chromadb.serverConfig helper template that builds a config dict from values and supports extraConfig merge for advanced users. Closes #123
There was a problem hiding this comment.
Pull request overview
This PR updates the Helm chart’s Chroma v1 (>= 1.0.0) configuration rendering to support wildcard CORS origins for the Rust server, while refactoring the v1 ConfigMap generation into a reusable helper and adding an extraConfig merge escape hatch.
Changes:
- Removes the v1-config template validation that rejected
cors_allow_origins: ["*"]. - Refactors v1 server config rendering into a
chromadb.serverConfighelper and adds.Values.chromadb.extraConfigmerge support. - Adds a shell-based template rendering test script for v1-config and updates documentation/values accordingly.
Reviewed changes
Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.
Show a summary per file
| File | Description |
|---|---|
tests/test_v1_config.sh |
Adds a Helm+yq-based test suite validating v1-config rendering scenarios (CORS, OTEL, extraConfig). |
charts/chromadb-chart/values.yaml |
Updates CORS comment and introduces chromadb.extraConfig with examples. |
charts/chromadb-chart/templates/config.yaml |
Replaces inline v1-config YAML rendering with a helper include. |
charts/chromadb-chart/templates/_helpers.tpl |
Introduces chromadb.serverConfig helper that builds the v1 config dict and merge-overwrites extraConfig. |
README.md |
Updates supported versions, documents wildcard CORS behavior, and adds extraConfig documentation. |
ISSUE_CONTEXT.md |
Adds captured issue context for #123. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
- Add {{ fail }} guards for extraConfig overriding port/listen_address
- Add validation for port <= 0 and maxPayloadSizeBytes <= 0
- Add validation for telemetry.enabled without endpoint
- Fix CORS wildcard documentation in README, values.yaml, and CLAUDE.md
- Remove auto-generated ISSUE_CONTEXT.md and add to .gitignore
- Add error handling to get_v1_config and assert_template_fails helper
- Add negative test cases for all new validations (24 tests passing)
There was a problem hiding this comment.
Pull request overview
Copilot reviewed 6 out of 7 changed files in this pull request and generated 5 comments.
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
| {{- $config = mergeOverwrite $config . -}} | ||
| {{- end -}} | ||
| {{- if ne (get $config "port" | int) ($port) -}} | ||
| {{- fail (printf "extraConfig.port (%v) conflicts with chromadb.serverHttpPort (%v) — update serverHttpPort instead" (get $config "port") $.Values.chromadb.serverHttpPort) -}} |
There was a problem hiding this comment.
The validation logic for extraConfig.port has a type conversion issue. Line 154 converts the config value to int, but if a user provides a string value in extraConfig (e.g., "9999"), the comparison ne (get $config "port" | int) ($port) may behave unexpectedly. The left side converts the potentially overridden value to int, while $port is already an int. This works, but the error message on line 155 uses (get $config "port") without the int conversion, which could display a string in the error message while comparing against an int. For consistency, either use (get $config "port" | int) in the error message or ensure type consistency throughout.
| {{- fail (printf "extraConfig.port (%v) conflicts with chromadb.serverHttpPort (%v) — update serverHttpPort instead" (get $config "port") $.Values.chromadb.serverHttpPort) -}} | |
| {{- fail (printf "extraConfig.port (%v) conflicts with chromadb.serverHttpPort (%v) — update serverHttpPort instead" (get $config "port" | int) $.Values.chromadb.serverHttpPort) -}} |
| assert_template_fails "telemetry.enabled without endpoint rejected" \ | ||
| --set 'chromadb.telemetry.enabled=true' | ||
|
|
||
| echo "" |
There was a problem hiding this comment.
Test 10 validates that CORS wildcard renders in v1-config for apiVersion 0.6.3 (pre-1.0), but this test is not meaningful because v1-config is only mounted and used for versions >= 1.0.0 (see statefulset.yaml lines 175-179 and 220-225). While the ConfigMap will render for all versions, it's effectively unused for < 1.0.0. This test gives false confidence that wildcard CORS works for pre-1.0 versions when in reality those versions use a different configuration mechanism. Consider either removing this test or adding a comment explaining that it only validates template rendering, not actual functionality for pre-1.0 versions.
| echo "" | |
| echo "" | |
| # NOTE: v1-config is only mounted and used for apiVersion >= 1.0.0. | |
| # For apiVersion < 1.0.0 (e.g. 0.6.3), this test only validates that the | |
| # Helm template renders the expected CORS wildcard in the ConfigMap; it | |
| # does NOT verify actual runtime CORS behavior for pre-1.0.0, which uses | |
| # a different configuration mechanism. |
| > Keys in `extraConfig` override chart-managed keys of the same name. When overriding `port` or | ||
| > `listen_address`, you must also update `chromadb.serverHttpPort` and `chromadb.serverHost` to match, | ||
| > otherwise the Service, container port, and health probes will be out of sync. |
There was a problem hiding this comment.
The documentation states "Keys in extraConfig override chart-managed keys of the same name" and warns users about needing to update serverHttpPort and serverHost when overriding port or listen_address. However, the actual implementation in _helpers.tpl (lines 154-159) PREVENTS these overrides by failing with an error message. The warning should be updated to clarify that overriding port or listen_address via extraConfig is not allowed and will cause template rendering to fail. The current wording suggests it's possible but problematic, when in fact it's explicitly blocked.
| > Keys in `extraConfig` override chart-managed keys of the same name. When overriding `port` or | |
| > `listen_address`, you must also update `chromadb.serverHttpPort` and `chromadb.serverHost` to match, | |
| > otherwise the Service, container port, and health probes will be out of sync. | |
| > Keys in `extraConfig` override chart-managed keys of the same name. Overriding `port` or | |
| > `listen_address` via `extraConfig` is **not allowed** and will cause Helm template rendering to fail. | |
| > To change the server port or host, use `chromadb.serverHttpPort` and `chromadb.serverHost` instead so | |
| > that the Service, container port, and health probes remain in sync. |
| {{- $otel := dict "service_name" .Values.chromadb.telemetry.serviceName "endpoint" .Values.chromadb.telemetry.endpoint -}} | ||
| {{- $_ := set $config "open_telemetry" $otel -}} | ||
| {{- end -}} | ||
| {{- with .Values.chromadb.extraConfig -}} |
There was a problem hiding this comment.
The use of mergeOverwrite allows users to inject arbitrary YAML keys into the server configuration through extraConfig. While this is intentional and documented, it could potentially allow users to override security-sensitive configuration options (beyond just port and listen_address which are explicitly blocked). Consider documenting any other keys that should not be overridden for security reasons, or implement additional validation to prevent overriding other sensitive keys like authentication-related settings if they exist in the v1 config format.
| {{- with .Values.chromadb.extraConfig -}} | |
| {{- with .Values.chromadb.extraConfig -}} | |
| {{- $disallowedKeys := list "auth" "authentication" "auth_token" "jwt" "security" -}} | |
| {{- range $k := $disallowedKeys -}} | |
| {{- if hasKey . $k -}} | |
| {{- fail (printf "chromadb.extraConfig cannot set '%s' because it is security-sensitive; use chromadb.auth.* Helm values instead" $k) -}} | |
| {{- end -}} | |
| {{- end -}} |
| {{- if le $port 0 -}} | ||
| {{- fail (printf "chromadb.serverHttpPort must be a positive integer, got: %v" .Values.chromadb.serverHttpPort) -}} | ||
| {{- end -}} | ||
| {{- $maxPayload := .Values.chromadb.maxPayloadSizeBytes | int64 -}} |
There was a problem hiding this comment.
The validation for maxPayloadSizeBytes at line 132 checks if the value is <= 0, but the conversion to int64 happens before the check. If the user provides a non-numeric value, the int64 function may return 0, which would then fail the validation with a potentially confusing error message saying "got: ". Consider adding explicit type checking or updating the error message to clarify that the value must be numeric.
| {{- $maxPayload := .Values.chromadb.maxPayloadSizeBytes | int64 -}} | |
| {{- $rawMaxPayload := .Values.chromadb.maxPayloadSizeBytes -}} | |
| {{- if not (regexMatch "^[0-9]+$" (toString $rawMaxPayload)) -}} | |
| {{- fail (printf "chromadb.maxPayloadSizeBytes must be a positive integer (numeric), got non-numeric value: %v" $rawMaxPayload) -}} | |
| {{- end -}} | |
| {{- $maxPayload := $rawMaxPayload | int64 -}} |
- README WARNING now states port/listen_address overrides are blocked - Add clarifying comment to test 10 about v1-config mount scope
Summary
["*"]validation for Chroma >= 1.0.0 — the Rust server supports itchromadb.serverConfighelper template in_helpers.tplchromadb.extraConfigescape hatch for merging arbitrary config keys into the v1 server configtests/test_v1_config.sh) with 21 assertionsTest plan
helm lintpasseshelm templatewith wildcard CORS on >= 1.0.0 renders correctlyhelm templatewith multiple CORS origins renders correctlyhelm templatewith OTEL enabled renders correctlyhelm templatewith custom server settings renders correctlyhelm templatewithextraConfigmerge renders correctlyhelm templatewithextraConfigoverride of chart-managed keys worksCloses #123
Partially addresses #127