Skip to content

chore: improved good defaults#34

Merged
SantiagoDePolonia merged 4 commits intomainfrom
chore/improved-good-defaults
Jan 16, 2026
Merged

chore: improved good defaults#34
SantiagoDePolonia merged 4 commits intomainfrom
chore/improved-good-defaults

Conversation

@SantiagoDePolonia
Copy link
Copy Markdown
Contributor

@SantiagoDePolonia SantiagoDePolonia commented Jan 16, 2026

Summary by CodeRabbit

  • Chores

    • Body/header logging now defaults to enabled when related environment variables are unset.
    • Removed several logging-related environment variables from the service configuration.
  • Documentation

    • Updated helper documentation to clarify that environment variables return their boolean value or a provided default when not set.

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

@SantiagoDePolonia SantiagoDePolonia self-assigned this Jan 16, 2026
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 16, 2026

📝 Walkthrough

Walkthrough

The PR changes default logging environment handling: config/config.go now defaults some logging booleans to true when env vars are unset and expands getEnvBoolOrDefault docs; docker-compose.yaml removes five logging-related environment variables from the gomodel service. (33 words)

Changes

Cohort / File(s) Summary
Configuration defaults
config/config.go
Default handling for logging booleans updated: LOGGING_LOG_BODIES and LOGGING_LOG_HEADERS now use getEnvBoolOrDefault(..., true) during Load() and initialization (previously used getEnvBool / defaulted false). Doc comment for getEnvBoolOrDefault expanded. No exported signatures changed.
Compose env cleanup
docker-compose.yaml
Removed five logging-related environment variables from the gomodel service: LOGGING_LOG_BODIES, LOGGING_LOG_HEADERS, LOGGING_BUFFER_SIZE, LOGGING_FLUSH_INTERVAL, LOGGING_RETENTION_DAYS.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~10 minutes

Poem

🐇 I nudged two flags to wake with the sun,
Env whispers now default to true, not none.
Five trailing vars I gently set aside,
A tidy hop, a small configuration glide.
I munch a carrot, pleased with this light stride.

🚥 Pre-merge checks | ✅ 3
✅ Passed checks (3 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title accurately reflects the main changes in the PR, which involve modifying default values for logging configuration to improve system defaults.
Docstring Coverage ✅ Passed Docstring coverage is 100.00% 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


📜 Recent review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 3cff445 and ffb0229.

📒 Files selected for processing (1)
  • config/config.go
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.go: All request/response payloads must use strongly-typed structs instead of interfaces{} or map[string]interface{} to catch errors at compile time
Use goroutines and channels for high-throughput scenarios (10k+ concurrent connections) to maintain concurrency design principles
Use the module name gomodel for all imports and package references

Files:

  • config/config.go
config/config.go

📄 CodeRabbit inference engine (CLAUDE.md)

config/config.go: Use Viper for loading configuration from environment variables and .env files in the config package
At least one provider API key is required in the environment configuration to start the server

Files:

  • config/config.go
🧠 Learnings (2)
📚 Learning: 2025-12-28T22:10:31.364Z
Learnt from: CR
Repo: ENTERPILOT/GOModel PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-28T22:10:31.364Z
Learning: Applies to config/config.go : Use `Viper` for loading configuration from environment variables and .env files in the config package

Applied to files:

  • config/config.go
📚 Learning: 2026-01-15T23:07:37.652Z
Learnt from: SantiagoDePolonia
Repo: ENTERPILOT/GOModel PR: 33
File: internal/auditlog/factory.go:112-143
Timestamp: 2026-01-15T23:07:37.652Z
Learning: Guideline: Do not use interface{} or map[string]interface{} for API request/response payload types. Prefer strongly-typed structs for API payload definitions to improve type safety, serialization, and documentation. Allow interface{} only in internal infrastructure code paths where pragmatic flexibility is necessary (e.g., to avoid import cycles or to handle highly dynamic internal contracts). In internal/auditlog/factory.go and similar non-API implementation files, applying this restriction is optional and should be evaluated on a case-by-case basis based on whether the type remains internal and does not define API boundary shapes.

Applied to files:

  • config/config.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (go)
🔇 Additional comments (1)
config/config.go (1)

435-437: Doc update looks good.
Clarifies the helper’s behavior succinctly.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.


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.

Copy link
Copy Markdown
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: 0

Caution

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

⚠️ Outside diff range comments (1)
config/config.go (1)

233-241: Align OnlyModelInteractions default across config sources (and fix CI unused helper).

Line 241 now uses getEnvBool, so when the env var is unset the env-only path defaults to false, while viper.SetDefault("logging.only_model_interactions", true) (Line 189) and the LogConfig comment (Line 70) still indicate a true default. This makes behavior depend on whether a config file exists and can unexpectedly broaden logging when enabled. Also, CI reports getEnvBoolOrDefault unused (Line 436).

If the intended default is still true, switch back to getEnvBoolOrDefault (fixes the lint error). If the intended default is now false, update the viper default and comment and remove the helper.

✅ Suggested fix (keep default true)
-				OnlyModelInteractions: getEnvBool("LOGGING_ONLY_MODEL_INTERACTIONS"),
+				OnlyModelInteractions: getEnvBoolOrDefault("LOGGING_ONLY_MODEL_INTERACTIONS", true),
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between e429eb0 and ac37a32.

📒 Files selected for processing (2)
  • config/config.go
  • docker-compose.yaml
💤 Files with no reviewable changes (1)
  • docker-compose.yaml
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.go: All request/response payloads must use strongly-typed structs instead of interfaces{} or map[string]interface{} to catch errors at compile time
Use goroutines and channels for high-throughput scenarios (10k+ concurrent connections) to maintain concurrency design principles
Use the module name gomodel for all imports and package references

Files:

  • config/config.go
config/config.go

📄 CodeRabbit inference engine (CLAUDE.md)

config/config.go: Use Viper for loading configuration from environment variables and .env files in the config package
At least one provider API key is required in the environment configuration to start the server

Files:

  • config/config.go
🧠 Learnings (2)
📚 Learning: 2025-12-28T22:10:31.364Z
Learnt from: CR
Repo: ENTERPILOT/GOModel PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-28T22:10:31.364Z
Learning: Applies to config/config.go : Use `Viper` for loading configuration from environment variables and .env files in the config package

Applied to files:

  • config/config.go
📚 Learning: 2026-01-15T23:07:37.652Z
Learnt from: SantiagoDePolonia
Repo: ENTERPILOT/GOModel PR: 33
File: internal/auditlog/factory.go:112-143
Timestamp: 2026-01-15T23:07:37.652Z
Learning: Guideline: Do not use interface{} or map[string]interface{} for API request/response payload types. Prefer strongly-typed structs for API payload definitions to improve type safety, serialization, and documentation. Allow interface{} only in internal infrastructure code paths where pragmatic flexibility is necessary (e.g., to avoid import cycles or to handle highly dynamic internal contracts). In internal/auditlog/factory.go and similar non-API implementation files, applying this restriction is optional and should be evaluated on a case-by-case basis based on whether the type remains internal and does not define API boundary shapes.

Applied to files:

  • config/config.go
🪛 GitHub Actions: CI
config/config.go

[error] 436-436: golangci-lint: config/config.go:436:6: func getEnvBoolOrDefault is unused (unused)

⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (go)

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

@SantiagoDePolonia
Copy link
Copy Markdown
Contributor Author

@coderabbitai rerun

@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 16, 2026

@SantiagoDePolonia: I'll rerun the review for this PR.

✅ Actions performed

Review triggered.

Note: CodeRabbit is an incremental review system and does not re-review already reviewed commits. This command is applicable only when automatic reviews are paused.

Copy link
Copy Markdown
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: 0

Caution

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

⚠️ Outside diff range comments (1)
config/config.go (1)

233-241: Align OnlyModelInteractions default across config paths.

In the env-only path, OnlyModelInteractions now defaults to false when LOGGING_ONLY_MODEL_INTERACTIONS is unset, but the struct comment and viper defaults still indicate true. This makes behavior dependent on whether a config file exists and can unintentionally broaden audit logging scope. Please align the defaults (either restore true here or update the viper defaults + doc comment to false).

🔧 Option A: restore the documented default (true) in env-only path
} else {
+		onlyModelInteractions := true
+		if v, ok := os.LookupEnv("LOGGING_ONLY_MODEL_INTERACTIONS"); ok {
+			onlyModelInteractions = strings.EqualFold(v, "true") || v == "1"
+		}
 		// No config file, use environment variables (legacy support)
 		cfg = Config{
 			Server: ServerConfig{
 				Port:          viper.GetString("PORT"),
@@
 			Logging: LogConfig{
 				Enabled:               getEnvBool("LOGGING_ENABLED"),
 				StorageType:           getEnvOrDefault("LOGGING_STORAGE_TYPE", "sqlite"),
 				LogBodies:             getEnvBool("LOGGING_LOG_BODIES"),
 				LogHeaders:            getEnvBool("LOGGING_LOG_HEADERS"),
 				BufferSize:            getEnvIntOrDefault("LOGGING_BUFFER_SIZE", 1000),
 				FlushInterval:         getEnvIntOrDefault("LOGGING_FLUSH_INTERVAL", 5),
 				RetentionDays:         getEnvIntOrDefault("LOGGING_RETENTION_DAYS", 30),
-				OnlyModelInteractions: getEnvBool("LOGGING_ONLY_MODEL_INTERACTIONS"),
+				OnlyModelInteractions: onlyModelInteractions,
 			},
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between ac37a32 and 499c621.

📒 Files selected for processing (1)
  • config/config.go
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.go: All request/response payloads must use strongly-typed structs instead of interfaces{} or map[string]interface{} to catch errors at compile time
Use goroutines and channels for high-throughput scenarios (10k+ concurrent connections) to maintain concurrency design principles
Use the module name gomodel for all imports and package references

Files:

  • config/config.go
config/config.go

📄 CodeRabbit inference engine (CLAUDE.md)

config/config.go: Use Viper for loading configuration from environment variables and .env files in the config package
At least one provider API key is required in the environment configuration to start the server

Files:

  • config/config.go
🧠 Learnings (2)
📚 Learning: 2025-12-28T22:10:31.364Z
Learnt from: CR
Repo: ENTERPILOT/GOModel PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-28T22:10:31.364Z
Learning: Applies to config/config.go : Use `Viper` for loading configuration from environment variables and .env files in the config package

Applied to files:

  • config/config.go
📚 Learning: 2026-01-15T23:07:37.652Z
Learnt from: SantiagoDePolonia
Repo: ENTERPILOT/GOModel PR: 33
File: internal/auditlog/factory.go:112-143
Timestamp: 2026-01-15T23:07:37.652Z
Learning: Guideline: Do not use interface{} or map[string]interface{} for API request/response payload types. Prefer strongly-typed structs for API payload definitions to improve type safety, serialization, and documentation. Allow interface{} only in internal infrastructure code paths where pragmatic flexibility is necessary (e.g., to avoid import cycles or to handle highly dynamic internal contracts). In internal/auditlog/factory.go and similar non-API implementation files, applying this restriction is optional and should be evaluated on a case-by-case basis based on whether the type remains internal and does not define API boundary shapes.

Applied to files:

  • config/config.go

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Good defaults have been added to config.go files for env variables.
Copy link
Copy Markdown
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: 1

🤖 Fix all issues with AI agents
In `@config/config.go`:
- Around line 236-237: The config defaults for LogBodies and LogHeaders are
currently set via getEnvBoolOrDefault("LOGGING_LOG_BODIES", true) and
getEnvBoolOrDefault("LOGGING_LOG_HEADERS", true) which contradicts the struct
comments and viper defaults and risks logging sensitive data; change the boolean
defaults to false (i.e., use getEnvBoolOrDefault(..., false)) so both LogBodies
and LogHeaders default to false unless explicitly enabled, and ensure any
related viper default logic (the Viper defaults that set these to false) remains
consistent with these changes.
📜 Review details

Configuration used: Organization UI

Review profile: ASSERTIVE

Plan: Pro

📥 Commits

Reviewing files that changed from the base of the PR and between 499c621 and 3cff445.

📒 Files selected for processing (1)
  • config/config.go
🧰 Additional context used
📓 Path-based instructions (2)
**/*.go

📄 CodeRabbit inference engine (CLAUDE.md)

**/*.go: All request/response payloads must use strongly-typed structs instead of interfaces{} or map[string]interface{} to catch errors at compile time
Use goroutines and channels for high-throughput scenarios (10k+ concurrent connections) to maintain concurrency design principles
Use the module name gomodel for all imports and package references

Files:

  • config/config.go
config/config.go

📄 CodeRabbit inference engine (CLAUDE.md)

config/config.go: Use Viper for loading configuration from environment variables and .env files in the config package
At least one provider API key is required in the environment configuration to start the server

Files:

  • config/config.go
🧠 Learnings (2)
📚 Learning: 2025-12-28T22:10:31.364Z
Learnt from: CR
Repo: ENTERPILOT/GOModel PR: 0
File: CLAUDE.md:0-0
Timestamp: 2025-12-28T22:10:31.364Z
Learning: Applies to config/config.go : Use `Viper` for loading configuration from environment variables and .env files in the config package

Applied to files:

  • config/config.go
📚 Learning: 2026-01-15T23:07:37.652Z
Learnt from: SantiagoDePolonia
Repo: ENTERPILOT/GOModel PR: 33
File: internal/auditlog/factory.go:112-143
Timestamp: 2026-01-15T23:07:37.652Z
Learning: Guideline: Do not use interface{} or map[string]interface{} for API request/response payload types. Prefer strongly-typed structs for API payload definitions to improve type safety, serialization, and documentation. Allow interface{} only in internal infrastructure code paths where pragmatic flexibility is necessary (e.g., to avoid import cycles or to handle highly dynamic internal contracts). In internal/auditlog/factory.go and similar non-API implementation files, applying this restriction is optional and should be evaluated on a case-by-case basis based on whether the type remains internal and does not define API boundary shapes.

Applied to files:

  • config/config.go
⏰ Context from checks skipped due to timeout of 90000ms. You can increase the timeout in your CodeRabbit configuration to a maximum of 15 minutes (900000ms). (1)
  • GitHub Check: Analyze (go)
🔇 Additional comments (1)
config/config.go (1)

435-436: LGTM!

The documentation update accurately describes the function behavior.

✏️ Tip: You can disable this entire section by setting review_details to false in your review settings.

Comment thread config/config.go
Comment on lines +236 to +237
LogBodies: getEnvBoolOrDefault("LOGGING_LOG_BODIES", true),
LogHeaders: getEnvBoolOrDefault("LOGGING_LOG_HEADERS", true),
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

⚠️ Potential issue | 🟠 Major

Defaulting to log bodies/headers raises security and consistency concerns.

  1. Privacy/Compliance risk: The struct comment at line 46 explicitly warns that LogBodies "may contain sensitive data (PII, API keys in prompts)". Defaulting this to true means sensitive user data is logged without explicit opt-in, which could violate GDPR/CCPA requirements.

  2. Documentation mismatch: The struct comments (lines 47-48, 52-53) state "Default: false" for both fields, but this code now defaults them to true.

  3. Inconsistent behavior: When a config file exists, viper defaults (lines 184-185) set these to false. When no config file exists (this code path), they now default to true. This creates unpredictable behavior depending on config file presence.

Consider either:

  • Keep defaults as false for security-by-default, requiring explicit opt-in
  • If true is intentional, update struct comments and viper defaults to match
🔒 Suggested fix for security-by-default approach
-				LogBodies:             getEnvBoolOrDefault("LOGGING_LOG_BODIES", true),
-				LogHeaders:            getEnvBoolOrDefault("LOGGING_LOG_HEADERS", true),
+				LogBodies:             getEnvBool("LOGGING_LOG_BODIES"),
+				LogHeaders:            getEnvBool("LOGGING_LOG_HEADERS"),
📝 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
LogBodies: getEnvBoolOrDefault("LOGGING_LOG_BODIES", true),
LogHeaders: getEnvBoolOrDefault("LOGGING_LOG_HEADERS", true),
LogBodies: getEnvBool("LOGGING_LOG_BODIES"),
LogHeaders: getEnvBool("LOGGING_LOG_HEADERS"),
🤖 Prompt for AI Agents
In `@config/config.go` around lines 236 - 237, The config defaults for LogBodies
and LogHeaders are currently set via getEnvBoolOrDefault("LOGGING_LOG_BODIES",
true) and getEnvBoolOrDefault("LOGGING_LOG_HEADERS", true) which contradicts the
struct comments and viper defaults and risks logging sensitive data; change the
boolean defaults to false (i.e., use getEnvBoolOrDefault(..., false)) so both
LogBodies and LogHeaders default to false unless explicitly enabled, and ensure
any related viper default logic (the Viper defaults that set these to false)
remains consistent with these changes.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

This PR improves default configuration values for logging by enabling body and header logging by default when the corresponding environment variables are not set. This allows the docker-compose configuration to be simplified by removing redundant environment variable declarations.

Changes:

  • Updated LogBodies and LogHeaders to default to true when environment variables are unset
  • Removed now-redundant logging environment variables from docker-compose.yaml
  • Improved documentation for the getEnvBoolOrDefault helper function

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated no comments.

File Description
docker-compose.yaml Removed 5 logging-related environment variables that now use sensible defaults
config/config.go Changed LogBodies and LogHeaders to use getEnvBoolOrDefault with true defaults; improved helper documentation
Comments suppressed due to low confidence (2)

config/config.go:47

  • The documentation comment states 'Default: false' but the code now sets the default to true (line 236). This should be updated to 'Default: true' to reflect the actual behavior.
	// LogBodies enables logging of full request/response bodies
	// WARNING: May contain sensitive data (PII, API keys in prompts)
	// Default: false

config/config.go:52

  • The documentation comment states 'Default: false' but the code now sets the default to true (line 237). This should be updated to 'Default: true' to reflect the actual behavior.
	// LogHeaders enables logging of request/response headers
	// Sensitive headers (Authorization, Cookie, etc.) are auto-redacted
	// Default: false

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Copy link
Copy Markdown
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Copilot reviewed 2 out of 2 changed files in this pull request and generated 1 comment.


💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment thread config/config.go
viper.SetDefault("logging.storage_type", "sqlite")
viper.SetDefault("logging.log_bodies", false)
viper.SetDefault("logging.log_headers", false)
viper.SetDefault("logging.log_bodies", true)
Copy link

Copilot AI Jan 16, 2026

Choose a reason for hiding this comment

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

Changing the default for LogBodies from false to true increases the risk of logging sensitive data (PII, API keys in prompts) as noted in the WARNING comment on line 46. While this may be intentional for "good defaults" in development, this change should be carefully considered for production environments. Consider whether the .env.template file should be updated to reflect this new default to prevent user confusion.

Suggested change
viper.SetDefault("logging.log_bodies", true)
viper.SetDefault("logging.log_bodies", false)

Copilot uses AI. Check for mistakes.
@SantiagoDePolonia SantiagoDePolonia merged commit 48c9d34 into main Jan 16, 2026
13 checks passed
@SantiagoDePolonia SantiagoDePolonia deleted the chore/improved-good-defaults branch March 22, 2026 14:23
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