Skip to content

Conversation

@renuka-fernando
Copy link
Contributor

@renuka-fernando renuka-fernando commented Jan 24, 2026

Purpose

Fix comments on #774

Summary by CodeRabbit

  • Documentation

    • Switched docs and examples from YAML (config.yaml) to TOML (config.toml) and updated samples across the repo.
    • Updated logging docs to list "text" (instead of "console") as the alternative format.
  • Bug Fixes

    • Made log format checks case-insensitive.
    • Enhanced operational logging to include richer telemetry for topic lifecycle operations.
  • Chores

    • Added TOML configs, removed legacy YAML files, updated default config paths to TOML, and updated policy config keys to snake_case.

✏️ Tip: You can customize this high-level summary in your review settings.

@renuka-fernando renuka-fernando marked this pull request as ready for review January 24, 2026 11:36
@coderabbitai
Copy link
Contributor

coderabbitai bot commented Jan 24, 2026

Walkthrough

The PR migrates configuration from YAML to TOML (adds config.toml, removes config.yaml), updates runtime flags/mounts/entrypoints to reference TOML, swaps Koanf parsers to TOML and adapts config loaders, updates docs/examples to TOML, and makes small logger/handler telemetry tweaks (case-insensitive format check and richer structured logs).

Changes

Cohort / File(s) Summary
Config format migration (primary runtime files)
gateway/configs/config.toml, gateway/configs/config.yaml (deleted), gateway/it/test-config.toml, gateway/it/test-config.yaml (deleted), gateway/policy-engine/configs/config-file-mode.toml, gateway/policy-engine/configs/config-file-mode.yaml (deleted)
Adds comprehensive TOML config files and removes corresponding YAML variants; test and policy-engine file-mode configs moved to TOML.
Runtime flags, mounts, and entrypoints
gateway/gateway-controller/cmd/controller/main.go, gateway/policy-engine/cmd/policy-engine/main.go, gateway/docker-compose.yaml, gateway/it/docker-compose.test.yaml, gateway/gateway-builder/templates/Dockerfile.policy-engine.tmpl, gateway/policy-engine/Dockerfile, .vscode/launch.json
Default config paths, container mounts, and CMD/flag defaults updated to point at TOML files instead of YAML.
Config parsing libraries & loader code
gateway/gateway-controller/go.mod, gateway/policy-engine/go.mod, gateway/gateway-controller/pkg/config/config.go, gateway/policy-engine/internal/config/config.go
Replaced Koanf YAML parser with TOML parser; updated loader/unmarshal flow to use TOML parsing and mapstructure decode hooks (duration parsing, defaults/population, validation).
Logger behavior and validation
gateway/gateway-controller/pkg/logger/logger.go, kubernetes/gateway-operator/internal/config/config.go, kubernetes/gateway-operator/pkg/logger/logger.go, kubernetes/helm/*, kubernetes/gateway-operator/config/*
Made format comparisons case-insensitive and changed documented/default development label from "console" to "text" (validation/messages/comments updated).
Structured logging and correlation context
gateway/gateway-controller/pkg/api/handlers/handlers.go, gateway/gateway-controller/pkg/xds/translator.go
Enhanced error logs in topic lifecycle to emit structured fields (counts/errors) and switched a debug log call to use a correlation-aware logger variable for consistent context.
Config key renames in policies/defaults
gateway/gateway-controller/default-policies/*, gateway/policies/*, policy-definition files
Updated defaultValue and config key names from camelCase to snake_case (e.g., keyprefixkey_prefix, maxentriesmax_entries) to match TOML conventions.
Documentation & samples
many files: docs/**, docs/gateway/**, docs/ai-gateway/**, kubernetes/**, gateway/gateway-controller/README.md, kubernetes/helm/**
Replaced config.yaml references with config.toml, converted many example blocks from YAML to TOML, and updated in-line comments to reference "text" instead of "console". Primarily editorial updates.
Build/dev tooling updates
gateway/gateway-controller/go.mod, gateway/policy-engine/go.mod, .vscode/launch.json
Dependency changes to add TOML parser and mapstructure, and updated local launch configs to reference TOML paths.

Estimated code review effort

🎯 4 (Complex) | ⏱️ ~45 minutes

Poem

🐰 I found a toml beneath the hay,
YAML nudged aside to play.
Logs now whisper "text" with glee,
Correlation hops with me.
A tiny config feast — hooray! 🥕✨

🚥 Pre-merge checks | ✅ 2 | ❌ 1
❌ Failed checks (1 warning)
Check name Status Explanation Resolution
Description check ⚠️ Warning The PR description is minimal and incomplete, stating only 'Fix comments on #774' without addressing required template sections like Purpose, Goals, Approach, Documentation, or Testing. Provide a comprehensive description following the template: explain the migration rationale, goals, technical approach, documentation updates, and test coverage for the YAML-to-TOML configuration migration.
✅ Passed checks (2 passed)
Check name Status Explanation
Title check ✅ Passed The title accurately summarizes the main change—migrating configuration format from YAML to TOML—which aligns with the extensive modifications throughout the codebase.
Docstring Coverage ✅ Passed Docstring coverage is 88.89% which is sufficient. The required threshold is 80.00%.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing touches
  • 📝 Generate docstrings

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

Comment @coderabbitai help to get the list of available commands and usage tips.

@renuka-fernando renuka-fernando changed the title Update logging docs in gateway controller Migrate configuration format from YAML to TOML Jan 24, 2026
Copy link
Contributor

@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: 5

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (5)
docs/ai-gateway/analytics/moesif-analytics.md (2)

25-26: Fix step numbering typo (“Sept” → “Step”).

User-facing instructions show “Sept 2/3”; should be “Step 2/3.”

🔧 Proposed fix
-> - Sept 2: Follow the onboarding wizard.
-> - Sept 3: During the sign up process, you will receive a Collector Application ID for your configured application. Copy this value and keep it saved.
+> - Step 2: Follow the onboarding wizard.
+> - Step 3: During the sign up process, you will receive a Collector Application ID for your configured application. Copy this value and keep it saved.

69-69: Fix typo in “private key” label.

“privare key” should be “private key.”

🔧 Proposed fix
-| `private_key_path`   | string | No       | - | Path to the privare key used for securing ALS communication when transport-level encryption or authentication is enabled.        |
+| `private_key_path`   | string | No       | - | Path to the private key used for securing ALS communication when transport-level encryption or authentication is enabled.        |
docs/ai-gateway/observability/tracing.md (1)

80-80: Minor text inconsistency with TOML syntax.

The text mentions "set enabled: false" using YAML-style colon syntax, but since the configuration is now TOML, it should reference enabled = false for consistency.

Suggested fix
-**Note:** If tracing is enabled in the configuration but the OTLP collector is not running, components will log warnings about failed trace exports. To completely disable tracing, set `enabled: false` in the configuration.
+**Note:** If tracing is enabled in the configuration but the OTLP collector is not running, components will log warnings about failed trace exports. To completely disable tracing, set `enabled = false` in the configuration.
docs/gateway/observability/metrics.md (1)

892-898: Use TOML key/value syntax in the troubleshooting note.

enabled: true is YAML; in TOML it should be enabled = true.

♻️ Proposed fix
-Ensure `enabled: true`.
+Ensure `enabled = true`.
docs/gateway/observability/tracing.md (1)

80-81: Use TOML syntax in the prose examples.

Replace enabled: false and enabled: true with enabled = false and enabled = true to match the actual TOML configuration format.

The documentation incorrectly uses YAML-style colon syntax at lines 80-81 and 730-736, while the actual config.toml uses TOML-style equals syntax.

🤖 Fix all issues with AI agents
In `@docs/gateway/observability/tracing.md`:
- Around line 41-51: The disablement guidance references a non-existent section
`[policy_engine.tracing]`; update the disable example to use the actual config
key `[tracing]` (matching the schema and the enable example) by removing any
`[policy_engine.tracing]` entries and replacing them with `[tracing]` so both
enable/disable examples consistently use the same `tracing` section and fields
(e.g., `enabled`, `endpoint`, `service_version`, `batch_timeout`,
`max_export_batch_size`, `sampling_rate`).

In `@gateway/configs/config.toml`:
- Around line 227-236: The shutdown_timeout field under
[analytics.access_logs_service] is a time.Duration and should be written as a
duration string (e.g. "600s") instead of the integer 600; update
shutdown_timeout to a quoted duration string like "600s" while leaving integer
nanosecond fields buffer_flush_interval and grpc_request_timeout under
[analytics.grpc_access_logs] unchanged.

In `@gateway/gateway-controller/pkg/config/config.go`:
- Line 26: The koanf unmarshal call using k.Unmarshal() does not supply a
DecodeHook so TOML duration strings (e.g., for ShutdownTimeout,
ReconnectInitial, ReconnectMax, PollingInterval, BatchTimeout) fail to decode
into time.Duration; replace the k.Unmarshal call (the one that populates cfg)
with k.UnmarshalWithConf using koanf.UnmarshalConf and a
mapstructure.DecoderConfig that sets TagName:"koanf", WeaklyTypedInput:true,
Result:cfg and DecodeHook:mapstructure.StringToTimeDurationHookFunc(); also add
the import for github.com/go-viper/mapstructure/v2 to enable
mapstructure.StringToTimeDurationHookFunc().

In `@gateway/it/test-config.toml`:
- Around line 182-194: The second policy_configurations.jwtauth_v010.keymanagers
entry (name "wrong-issuer-km") defines jwks.remote using the same TOML section
path as the first element, causing a collision; fix by embedding the jwks.remote
object inside that array element using inline table syntax (e.g. set jwks = {
remote = { uri = "http://mock-jwks:8080/jwks" } } for the keymanager with name
"wrong-issuer-km") so each policy_configurations.jwtauth_v010.keymanagers
element (mock-jwks and wrong-issuer-km) carries its own jwks.remote config and
avoids shared/overwritten sections.

In `@gateway/policy-engine/internal/config/config.go`:
- Line 26: The TOML duration fields in the config structs (ConnectTimeout,
RequestTimeout, InitialReconnectDelay, MaxReconnectDelay, BatchTimeout,
ShutdownTimeout) are currently unmarshaled by Load() expecting integer
nanoseconds, which will break if users supply Go-style strings like "10s";
update Load() to add a mapstructure DecodeHook that converts string duration
values to time.Duration (parsing via time.ParseDuration) before assignment, and
ensure the DecodeHook is registered with k.Unmarshal (or the koanf/decoder) so
strings like "10s" are accepted, or alternatively add a clear comment/example
near the config struct definitions and Load() documentation stating that
durations must be integer nanoseconds if you choose not to add the DecodeHook.
🧹 Nitpick comments (9)
.vscode/launch.json (1)

53-57: Minor formatting inconsistency.

There's an extra space before the comma on line 54. While valid JSON, it's inconsistent with the other configurations.

🔧 Suggested fix
-                "-config", "${workspaceFolder}/gateway/configs/config.toml" ,
+                "-config", "${workspaceFolder}/gateway/configs/config.toml",
docs/gateway/policies/advanced-ratelimit.md (1)

403-416: Consider aligning parameter names between tables and examples.

The parameter tables (lines 243-266) document keys in camelCase (e.g., keyPrefix, failureMode, includeXRateLimit), but the TOML examples use all-lowercase (e.g., keyprefix, failuremode, includexratelimit).

Based on learnings, the policy engine validates configuration paths case-insensitively, so both will work. However, aligning the examples with the documented table format would improve documentation consistency and reduce potential confusion.

docs/ai-gateway/observability/tracing.md (1)

389-393: Remaining YAML syntax should be converted to TOML.

These gateway configuration snippets for alternative backends (Tempo, Datadog, Istio, Linkerd) still use YAML syntax. Since the gateway configuration has migrated to TOML, these should be updated for consistency.

Example fix for Tempo configuration
-Configure gateway to send directly to Tempo:
-```yaml
-tracing:
-  endpoint: tempo:4317
-```
+Configure gateway to send directly to Tempo:
+```toml
+[tracing]
+endpoint = "tempo:4317"
+```

Similar updates needed for lines 467-471 (Datadog), 513-517 (Istio), and 523-527 (Linkerd).

gateway/gateway-controller/cmd/controller/main.go (1)

45-45: Default config path update looks good; remember to rebuild gateway images.

Line 45 aligns with the TOML migration. Per gateway guidelines, rebuild images via cd gateway && make build-local.

gateway/docker-compose.yaml (1)

37-60: Remember to rebuild gateway images after this config path change.

Run cd gateway && make build-local so local images reflect the new config.toml paths. As per coding guidelines, ...

gateway/configs/config.toml (4)

127-131: Security: Default credentials should include a prominent warning.

Hardcoded admin/admin credentials with password_hashed = false pose a risk if users deploy without changing them. Consider adding a comment warning that these must be changed for production, or use placeholder values that will fail authentication until configured.

 [[gateway_controller.auth.basic.users]]
+# WARNING: Change these credentials before deploying to production!
 username = "admin"
-password = "admin"
+password = "CHANGE_ME"
 password_hashed = false
 roles = ["admin"]

184-186: Consider aligning log level with gateway_controller.

The policy engine defaults to "debug" while gateway_controller uses "info". Debug level is typically too verbose for production defaults and may impact performance. Consider setting both to "info" for consistency.

 [policy_engine.logging]
-level = "debug"
+level = "info"
 format = "json"

247-254: High default sampling rate may impact production performance.

sampling_rate = 1.0 means 100% of requests will be traced when tracing is enabled. This can cause significant overhead in production. Consider a lower default (e.g., 0.1 for 10%) with a comment explaining the trade-off.

 [tracing]
 enabled = false
 endpoint = "otel-collector:4317"
 insecure = true
 service_version = "1.0.0"
 batch_timeout = "1s"
 max_export_batch_size = 512
-sampling_rate = 1.0
+# Sampling rate: 1.0 = 100%, 0.1 = 10%. Lower values recommended for production.
+sampling_rate = 0.1

196-207: Naming convention inconsistency (may be intentional).

The policy_configurations section uses camelCase (maxEntries, cleanupInterval, includeXRateLimit) while the rest of the file uses snake_case. Based on learnings, the policy engine validates paths case-insensitively, so this works functionally. If this matches existing policy definition conventions, it's fine to keep; otherwise, consider aligning with the file's snake_case convention.

Comment on lines +182 to +194
[[policy_configurations.jwtauth_v010.keymanagers]]
name = "mock-jwks"
issuer = "http://mock-jwks:8080/token"

[policy_configurations.jwtauth_v010.keymanagers.jwks.remote]
uri = "http://mock-jwks:8080/jwks"

[[policy_configurations.jwtauth_v010.keymanagers]]
name = "wrong-issuer-km"
issuer = "http://expected-issuer.com"

[policy_configurations.jwtauth_v010.keymanagers.jwks.remote]
uri = "http://mock-jwks:8080/jwks"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

TOML array syntax issue for nested configuration.

The second [[policy_configurations.jwtauth_v010.keymanagers]] entry (lines 189-194) has its jwks.remote section defined with the same path as the first entry. In TOML, this won't correctly associate the jwks.remote with the second array element. The section at line 193 will overwrite or conflict with the one at line 186.

For inline nested objects in array elements, use inline table syntax or restructure the configuration.

Proposed fix
 [[policy_configurations.jwtauth_v010.keymanagers]]
 name = "wrong-issuer-km"
 issuer = "http://expected-issuer.com"
-
-[policy_configurations.jwtauth_v010.keymanagers.jwks.remote]
-uri = "http://mock-jwks:8080/jwks"
+jwks = { remote = { uri = "http://mock-jwks:8080/jwks" } }
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
[[policy_configurations.jwtauth_v010.keymanagers]]
name = "mock-jwks"
issuer = "http://mock-jwks:8080/token"
[policy_configurations.jwtauth_v010.keymanagers.jwks.remote]
uri = "http://mock-jwks:8080/jwks"
[[policy_configurations.jwtauth_v010.keymanagers]]
name = "wrong-issuer-km"
issuer = "http://expected-issuer.com"
[policy_configurations.jwtauth_v010.keymanagers.jwks.remote]
uri = "http://mock-jwks:8080/jwks"
[[policy_configurations.jwtauth_v010.keymanagers]]
name = "mock-jwks"
issuer = "http://mock-jwks:8080/token"
[policy_configurations.jwtauth_v010.keymanagers.jwks.remote]
uri = "http://mock-jwks:8080/jwks"
[[policy_configurations.jwtauth_v010.keymanagers]]
name = "wrong-issuer-km"
issuer = "http://expected-issuer.com"
jwks = { remote = { uri = "http://mock-jwks:8080/jwks" } }
🤖 Prompt for AI Agents
In `@gateway/it/test-config.toml` around lines 182 - 194, The second
policy_configurations.jwtauth_v010.keymanagers entry (name "wrong-issuer-km")
defines jwks.remote using the same TOML section path as the first element,
causing a collision; fix by embedding the jwks.remote object inside that array
element using inline table syntax (e.g. set jwks = { remote = { uri =
"http://mock-jwks:8080/jwks" } } for the keymanager with name "wrong-issuer-km")
so each policy_configurations.jwtauth_v010.keymanagers element (mock-jwks and
wrong-issuer-km) carries its own jwks.remote config and avoids
shared/overwritten sections.

Copy link
Contributor

@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: 4

Caution

Some comments are outside the diff and can’t be posted inline due to platform limitations.

⚠️ Outside diff range comments (3)
docs/ai-gateway/observability/tracing.md (1)

80-80: Use TOML syntax in prose to avoid confusion.

These lines still show YAML-style enabled: .... For TOML, the doc should say enabled = false / enabled = true.

✏️ Suggested doc fix
-**Note:** If tracing is enabled in the configuration but the OTLP collector is not running, components will log warnings about failed trace exports. To completely disable tracing, set `enabled: false` in the configuration.
+**Note:** If tracing is enabled in the configuration but the OTLP collector is not running, components will log warnings about failed trace exports. To completely disable tracing, set `enabled = false` in the configuration.
-Ensure `enabled: true`.
+Ensure `enabled = true`.

Also applies to: 735-735

docs/ai-gateway/llm/semantic-caching.md (1)

48-49: Clarify override guidance for systemParameters.
Current text says system parameters can be overridden from API artifact params, which conflicts with the repo guidance that systemParameters must be configured exclusively in the gateway config file and referenced via wso2/defaultValue paths. Please align this sentence with that rule to avoid misconfiguration. Based on learnings, ...

docs/gateway/observability/metrics.md (1)

892-898: Fix YAML-style wording in TOML troubleshooting note.
The note below the command still references enabled: true, which is YAML syntax.

💡 Suggested doc tweak
-Ensure `enabled: true`.
+Ensure `enabled = true`.
🤖 Fix all issues with AI agents
In `@docs/ai-gateway/llm/guardrails/semantic-prompt-guard.md`:
- Around line 54-67: Remove the unused embedding_provider_dimension entry from
the example config.toml in the Semantic Prompt Guard docs: the Semantic Prompt
Guard policy only needs embedding_provider, embedding_provider_endpoint,
embedding_provider_model, and embedding_provider_api_key, so delete the
embedding_provider_dimension line from the config example and update the
surrounding explanatory text to not mention a dimension parameter (references:
embedding_provider_dimension, Semantic Prompt Guard policy).

In `@docs/ai-gateway/llm/semantic-caching.md`:
- Around line 79-94: The docs currently show flat config keys (e.g.,
embedding_provider, vector_db_provider_*) but must be moved under the namespaced
section policy_configurations.semantic_cache_v010 (i.e., wrap those keys inside
[policy_configurations.semantic_cache_v010]); also update any policy definition
default references (wso2/defaultValue) to the full path form such as
${config.policy_configurations.semantic_cache_v010.embedding_provider} instead
of ${config.embedding_provider}, and similarly replace other ${config.<key>}
uses with ${config.policy_configurations.semantic_cache_v010.<key>} for
vector_db_provider_*, embedding_provider_*, etc.

In `@docs/gateway/policies/advanced-ratelimit.md`:
- Around line 422-442: The TOML example under
[policy_configurations.ratelimit_v010.redis] and
[policy_configurations.ratelimit_v010.headers] uses lowercase keys that mismatch
the documented camelCase parameters; update the TOML keys to use the camelCase
names used by the config parser: change keyprefix → keyPrefix, failuremode →
failureMode, connectiontimeout → connectionTimeout, readtimeout → readTimeout,
writetimeout → writeTimeout, includexratelimit → includeXRateLimit, includeietf
→ includeIETF, and includeretryafter → includeRetryAfter so the example matches
the tables and parser.
- Around line 403-416: Update the TOML example under
[policy_configurations.ratelimit_v010] so the keys use the camelCase names
expected by the parser and docs: in the
[policy_configurations.ratelimit_v010.memory] section rename maxentries ->
maxEntries and cleanupinterval -> cleanupInterval; in the
[policy_configurations.ratelimit_v010.headers] section rename includexratelimit
-> includeXRateLimit, includeietf -> includeIETF, and includeretryafter ->
includeRetryAfter; ensure the modified keys align with the Go implementation and
the documentation tables for policy_configurations.ratelimit_v010.
♻️ Duplicate comments (4)
docs/gateway/observability/tracing.md (1)

820-826: Remove [policy_engine.tracing] from disablement guidance.

The config schema uses [tracing] exclusively. The enable section correctly shows [tracing], but this disable section includes [policy_engine.tracing] which does not exist in the configuration schema. Update to use only [tracing] for consistency.

Suggested fix
-```toml
-[policy_engine.tracing]
-enabled = false
-
-[tracing]
-enabled = false
-```
+```toml
+[tracing]
+enabled = false
+```
gateway/policy-engine/internal/config/config.go (1)

236-238: Add DecodeHook to parse TOML string durations into time.Duration fields.

The config structs contain multiple time.Duration fields (ConnectTimeout, RequestTimeout, InitialReconnectDelay, MaxReconnectDelay, BatchTimeout, ShutdownTimeout). With koanf v2.3.0 and TOML parsing, k.Unmarshal() at line 236 will fail to decode string durations (e.g., "10s") without mapstructure.StringToTimeDurationHookFunc().

Proposed fix using UnmarshalWithConf
+	"github.com/go-viper/mapstructure/v2"
 	// Unmarshal into Config struct
-	if err := k.Unmarshal("", cfg); err != nil {
+	if err := k.UnmarshalWithConf("", cfg, koanf.UnmarshalConf{
+		DecoderConfig: &mapstructure.DecoderConfig{
+			TagName:          "koanf",
+			WeaklyTypedInput: true,
+			DecodeHook:       mapstructure.StringToTimeDurationHookFunc(),
+			Result:           cfg,
+		},
+	}); err != nil {
 		return nil, fmt.Errorf("failed to unmarshal config: %w", err)
 	}
gateway/gateway-controller/pkg/config/config.go (1)

372-374: Add DecodeHook to unmarshal TOML string durations into time.Duration fields.

The config structs contain multiple time.Duration fields (ShutdownTimeout, BatchTimeout, ReconnectInitial, ReconnectMax, PollingInterval). With koanf v2.3.0 and TOML parsing, k.Unmarshal() at line 372 will fail to decode string durations (e.g., "15s") without mapstructure.StringToTimeDurationHookFunc().

Proposed fix using UnmarshalWithConf
+	"github.com/go-viper/mapstructure/v2"
 	// Unmarshal into Config struct
-	if err := k.Unmarshal("", cfg); err != nil {
+	if err := k.UnmarshalWithConf("", cfg, koanf.UnmarshalConf{
+		DecoderConfig: &mapstructure.DecoderConfig{
+			TagName:          "koanf",
+			WeaklyTypedInput: true,
+			DecodeHook:       mapstructure.StringToTimeDurationHookFunc(),
+			Result:           cfg,
+		},
+	}); err != nil {
 		return nil, fmt.Errorf("failed to unmarshal config: %w", err)
 	}
gateway/it/test-config.toml (1)

182-194: Duplicate: nested table collides across keymanagers entries.

This repeats the earlier concern: [policy_configurations.jwtauth_v010.keymanagers.jwks.remote] declared after each [[...keymanagers]] can collide or attach only to the most recent element in TOML. Consider inline tables per element or explicit nested tables scoped to each array entry.

TOML array-of-tables nested table behavior: how does [a.b.c] associate with [[a.b]] elements?
🧹 Nitpick comments (1)
gateway/gateway-controller/cmd/controller/main.go (1)

45-46: Rebuild gateway images after default config change.
Please run cd gateway && make build-local so local images reflect the new TOML default. As per coding guidelines, rebuild is required after gateway component changes.

@@ -0,0 +1,254 @@
# Gateway Controller and Policy Engine Configuration
Copy link
Contributor

Choose a reason for hiding this comment

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

Shall we keep only necessary values in here and move all others to template.toml as a documentation purpose.

Copy link
Contributor

@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: 2

🤖 Fix all issues with AI agents
In `@docs/gateway/observability/tracing.md`:
- Around line 199-201: Replace the invalid example that sets a top-level
policy_engine.service_name with a valid policy_engine configuration: remove the
`service_name` key and instead show nested tables such as
`[policy_engine.server]`, `[policy_engine.admin]`, `[policy_engine.xds]` and
include real keys like `extproc_port`, `enabled`, and `server_address` (e.g.,
`[policy_engine.server] extproc_port = <port>`, `[policy_engine.admin] enabled =
true`, `[policy_engine.xds] server_address = "<addr>"`) so the docs match the
actual config structure used by the policy_engine code paths.

In `@gateway/policy-engine/internal/config/config.go`:
- Around line 343-361: The current logic treats an empty
cfg.TracingConfig.Endpoint as "section missing" and replaces cfg.TracingConfig
with defaults.TracingConfig which can overwrite a user-set Enabled flag;
preserve user intent by using Enabled as the presence marker or by saving
cfg.TracingConfig.Enabled before assigning defaults and restoring it afterward.
Update the block around TracingConfig handling (refs: cfg.TracingConfig,
defaults.TracingConfig, Enabled) so that if Endpoint is empty you either check
cfg.TracingConfig.Enabled to decide whether to apply defaults, or copy the
existing Enabled value, assign defaults, and then restore the preserved Enabled
boolean so a user who set tracing.enabled=true won’t be silently disabled.

Comment on lines +199 to +201
```toml
[policy_engine]
service_name = "policy-engine-prod-us-east-1"
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
# Check the policy_engine section in the config file
rg -n '^\[policy_engine\]' -A10 gateway/configs/config.toml

Repository: wso2/api-platform

Length of output: 43


🏁 Script executed:

#!/bin/bash
# Check if the file exists
ls -la gateway/configs/config.toml 2>/dev/null || echo "File not found at that path"

# Search for policy_engine in all config-related files
rg -l 'policy_engine' gateway/configs/ 2>/dev/null || echo "No matches in gateway/configs"

# Search for policy_engine anywhere in the codebase
rg -l 'policy_engine' --type toml --type yaml --type yml 2>/dev/null | head -20

# Find all config.toml files
fd 'config.toml' gateway/

Repository: wso2/api-platform

Length of output: 221


🏁 Script executed:

#!/bin/bash
# Search for policy_engine section in the config file
rg -n 'policy_engine' gateway/configs/config.toml -B2 -A10

Repository: wso2/api-platform

Length of output: 1904


🏁 Script executed:

#!/bin/bash
# Search for service_name in the entire config file
rg -n 'service_name' gateway/configs/config.toml

# Check for a standalone [policy_engine] section (not subsections)
rg -n '^\[policy_engine\]$' gateway/configs/config.toml

Repository: wso2/api-platform

Length of output: 95


🏁 Script executed:

#!/bin/bash
# Show the complete policy_engine sections from config file to understand actual structure
rg -n '^\[policy_engine' gateway/configs/config.toml -A3

Repository: wso2/api-platform

Length of output: 728


Remove the invalid service_name example and replace with correct policy_engine configuration.

The service_name key does not exist under [policy_engine] in gateway/configs/config.toml. The actual configuration uses nested sections like [policy_engine.server], [policy_engine.admin], [policy_engine.xds], etc., with keys such as extproc_port, enabled, and server_address. Update the documentation to show valid policy_engine configuration.

🤖 Prompt for AI Agents
In `@docs/gateway/observability/tracing.md` around lines 199 - 201, Replace the
invalid example that sets a top-level policy_engine.service_name with a valid
policy_engine configuration: remove the `service_name` key and instead show
nested tables such as `[policy_engine.server]`, `[policy_engine.admin]`,
`[policy_engine.xds]` and include real keys like `extproc_port`, `enabled`, and
`server_address` (e.g., `[policy_engine.server] extproc_port = <port>`,
`[policy_engine.admin] enabled = true`, `[policy_engine.xds] server_address =
"<addr>"`) so the docs match the actual config structure used by the
policy_engine code paths.

Comment on lines +343 to +361
// TracingConfig - Only fill defaults if the whole section wasn't configured
// We check Endpoint as a marker that the section exists
if cfg.TracingConfig.Endpoint == "" {
cfg.TracingConfig = defaults.TracingConfig
} else {
// Partially fill in defaults for unset fields within tracing
if cfg.TracingConfig.ServiceVersion == "" {
cfg.TracingConfig.ServiceVersion = defaults.TracingConfig.ServiceVersion
}
if cfg.TracingConfig.BatchTimeout == 0 {
cfg.TracingConfig.BatchTimeout = defaults.TracingConfig.BatchTimeout
}
if cfg.TracingConfig.MaxExportBatchSize == 0 {
cfg.TracingConfig.MaxExportBatchSize = defaults.TracingConfig.MaxExportBatchSize
}
if cfg.TracingConfig.SamplingRate == 0 {
cfg.TracingConfig.SamplingRate = defaults.TracingConfig.SamplingRate
}
}
Copy link
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟡 Minor

TracingConfig defaults logic may silently override user intent.

If a user sets tracing.enabled = true without specifying endpoint, the entire section gets replaced with defaults (including Enabled: false). This could silently disable tracing when the user's intent was to enable it.

Consider checking cfg.TracingConfig.Enabled as a marker that the section was configured, or preserve the Enabled field before replacing:

♻️ Suggested fix
 	// TracingConfig - Only fill defaults if the whole section wasn't configured
-	// We check Endpoint as a marker that the section exists
-	if cfg.TracingConfig.Endpoint == "" {
+	// We check if the section was configured by examining multiple fields
+	tracingConfigured := cfg.TracingConfig.Endpoint != "" || cfg.TracingConfig.Enabled
+	if !tracingConfigured {
 		cfg.TracingConfig = defaults.TracingConfig
 	} else {
+		// Fill Endpoint default if not set but section is configured
+		if cfg.TracingConfig.Endpoint == "" {
+			cfg.TracingConfig.Endpoint = defaults.TracingConfig.Endpoint
+		}
 		// Partially fill in defaults for unset fields within tracing
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
// TracingConfig - Only fill defaults if the whole section wasn't configured
// We check Endpoint as a marker that the section exists
if cfg.TracingConfig.Endpoint == "" {
cfg.TracingConfig = defaults.TracingConfig
} else {
// Partially fill in defaults for unset fields within tracing
if cfg.TracingConfig.ServiceVersion == "" {
cfg.TracingConfig.ServiceVersion = defaults.TracingConfig.ServiceVersion
}
if cfg.TracingConfig.BatchTimeout == 0 {
cfg.TracingConfig.BatchTimeout = defaults.TracingConfig.BatchTimeout
}
if cfg.TracingConfig.MaxExportBatchSize == 0 {
cfg.TracingConfig.MaxExportBatchSize = defaults.TracingConfig.MaxExportBatchSize
}
if cfg.TracingConfig.SamplingRate == 0 {
cfg.TracingConfig.SamplingRate = defaults.TracingConfig.SamplingRate
}
}
// TracingConfig - Only fill defaults if the whole section wasn't configured
// We check if the section was configured by examining multiple fields
tracingConfigured := cfg.TracingConfig.Endpoint != "" || cfg.TracingConfig.Enabled
if !tracingConfigured {
cfg.TracingConfig = defaults.TracingConfig
} else {
// Fill Endpoint default if not set but section is configured
if cfg.TracingConfig.Endpoint == "" {
cfg.TracingConfig.Endpoint = defaults.TracingConfig.Endpoint
}
// Partially fill in defaults for unset fields within tracing
if cfg.TracingConfig.ServiceVersion == "" {
cfg.TracingConfig.ServiceVersion = defaults.TracingConfig.ServiceVersion
}
if cfg.TracingConfig.BatchTimeout == 0 {
cfg.TracingConfig.BatchTimeout = defaults.TracingConfig.BatchTimeout
}
if cfg.TracingConfig.MaxExportBatchSize == 0 {
cfg.TracingConfig.MaxExportBatchSize = defaults.TracingConfig.MaxExportBatchSize
}
if cfg.TracingConfig.SamplingRate == 0 {
cfg.TracingConfig.SamplingRate = defaults.TracingConfig.SamplingRate
}
}
🤖 Prompt for AI Agents
In `@gateway/policy-engine/internal/config/config.go` around lines 343 - 361, The
current logic treats an empty cfg.TracingConfig.Endpoint as "section missing"
and replaces cfg.TracingConfig with defaults.TracingConfig which can overwrite a
user-set Enabled flag; preserve user intent by using Enabled as the presence
marker or by saving cfg.TracingConfig.Enabled before assigning defaults and
restoring it afterward. Update the block around TracingConfig handling (refs:
cfg.TracingConfig, defaults.TracingConfig, Enabled) so that if Endpoint is empty
you either check cfg.TracingConfig.Enabled to decide whether to apply defaults,
or copy the existing Enabled value, assign defaults, and then restore the
preserved Enabled boolean so a user who set tracing.enabled=true won’t be
silently disabled.

description: Prefix for all Redis keys to avoid conflicts
default: "ratelimit:v1:"
"wso2/defaultValue": "${config.policy_configurations.ratelimit_v010.redis.keyprefix}"
"wso2/defaultValue": "${config.policy_configurations.ratelimit_v010.redis.key_prefix}"
Copy link
Contributor

Choose a reason for hiding this comment

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

We need to remove policies from here as well and add this changes to controller repo

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