Skip to content

Conversation

sawka
Copy link
Member

@sawka sawka commented Aug 26, 2025

No description provided.

Copy link
Contributor

coderabbitai bot commented Aug 26, 2025

Warning

Rate limit exceeded

@sawka has exceeded the limit for the number of commits or files that can be reviewed per hour. Please wait 22 minutes and 49 seconds before requesting another review.

⌛ How to resolve this issue?

After the wait time has elapsed, a review can be triggered using the @coderabbitai review command as a PR comment. Alternatively, push new commits to this PR.

We recommend that you space out your commits to avoid hitting the rate limit.

🚦 How do rate limits work?

CodeRabbit enforces hourly rate limits for each developer per organization.

Our paid plans have higher rate limits than the trial, open-source and free plans. In all cases, we re-allow further reviews after a brief timeout.

Please see our FAQ for further information.

📥 Commits

Reviewing files that changed from the base of the PR and between 56f0389 and 2ede0ec.

📒 Files selected for processing (2)
  • docs/docs/config.mdx (2 hunks)
  • pkg/wconfig/settingsconfig.go (2 hunks)
✨ Finishing Touches
  • 📝 Generate Docstrings
🧪 Generate unit tests
  • Create PR with unit tests
  • Post copyable unit tests in a comment
  • Commit unit tests in branch sawka/config-env

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
🪧 Tips

Chat

There are 3 ways to chat with CodeRabbit:

  • Review comments: Directly reply to a review comment made by CodeRabbit. Example:
    • I pushed a fix in commit <commit_id>, please review it.
    • Open a follow-up GitHub issue for this discussion.
  • Files and specific lines of code (under the "Files changed" tab): Tag @coderabbitai in a new review comment at the desired location with your query.
  • PR comments: Tag @coderabbitai in a new PR comment to ask questions about the PR branch. For the best results, please provide a very specific query, as very limited context is provided in this mode. Examples:
    • @coderabbitai gather interesting stats about this repository and render them as a table. Additionally, render a pie chart showing the language distribution in the codebase.
    • @coderabbitai read the files in the src/scheduler package and generate a class diagram using mermaid and a README in the markdown format.

Support

Need help? Create a ticket on our support page for assistance with any issues or questions.

CodeRabbit Commands (Invoked using PR/Issue comments)

Type @coderabbitai help to get the list of available commands.

Other keywords and placeholders

  • Add @coderabbitai ignore anywhere in the PR description to prevent this PR from being reviewed.
  • Add @coderabbitai summary to generate the high-level summary at a specific location in the PR description.
  • Add @coderabbitai anywhere in the PR title to generate the title automatically.

CodeRabbit Configuration File (.coderabbit.yaml)

  • You can programmatically configure CodeRabbit by adding a .coderabbit.yaml file to the root of your repository.
  • Please see the configuration documentation for more information.
  • If your editor has YAML language server enabled, you can add the path at the top of this file to enable auto-completion and validation: # yaml-language-server: $schema=https://coderabbit.ai/integrations/schema.v2.json

Status, Documentation and Community

  • Visit our Status Page to check the current availability of CodeRabbit.
  • Visit our Documentation for detailed information on how to use CodeRabbit.
  • Join our Discord Community to get help, request features, and share feedback.
  • Follow us on X/Twitter for updates and announcements.

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: 1

🧹 Nitpick comments (3)
pkg/wconfig/settingsconfig.go (3)

330-347: Handle nested MetaMapType and prefer any over interface{} for consistency

Today this only recurses into map[string]interface{} and []interface{}. If a nested value ever arrives as waveobj.MetaMapType (e.g., produced programmatically before serialization) it will be skipped. Also, the codebase already uses any; aligning here avoids mixed idioms.

Apply this diff (pairs with the next comment that updates resolveEnvArray to []any):

-  for key, value := range m {
+  for key, value := range m {
     switch v := value.(type) {
     case string:
       if resolved, ok := resolveEnvValue(v); ok {
         m[key] = resolved
       }
-    case map[string]interface{}:
-      resolveEnvReplacements(waveobj.MetaMapType(v))
-    case []interface{}:
-      resolveEnvArray(v)
+    case map[string]any:
+      resolveEnvReplacements(waveobj.MetaMapType(v))
+    case waveobj.MetaMapType:
+      resolveEnvReplacements(v)
+    case []any:
+      resolveEnvArray(v)
     }
   }

349-362: Harmonize array handling to []any and include waveobj.MetaMapType in recursion

JSON unmarshal yields []any; switching the signature and cases makes both functions consistent. Adding the MetaMapType arm improves robustness for programmatically constructed configs.

-func resolveEnvArray(arr []interface{}) {
+func resolveEnvArray(arr []any) {
   for i, value := range arr {
     switch v := value.(type) {
     case string:
       if resolved, ok := resolveEnvValue(v); ok {
         arr[i] = resolved
       }
-    case map[string]interface{}:
-      resolveEnvReplacements(waveobj.MetaMapType(v))
-    case []interface{}:
-      resolveEnvArray(v)
+    case map[string]any:
+      resolveEnvReplacements(waveobj.MetaMapType(v))
+    case waveobj.MetaMapType:
+      resolveEnvReplacements(v)
+    case []any:
+      resolveEnvArray(v)
     }
   }
 }

415-420: Ensure correct type conversion for environment‐variable overrides

We’ve confirmed that utilfn.ReUnmarshal simply does

barr, _ := json.Marshal(in)
json.Unmarshal(barr, out)

and that resolveEnvReplacements only replaces “$ENV:…” tokens with raw strings. The Go JSON package does not automatically convert JSON strings into numeric or boolean Go fields (e.g. float64, int64, bool, or their pointer variants). As a result, any $ENV:… override on a non‐string setting will either cause the unmarshal to fail (and be silently ignored, leaving a zero‐value) or never apply at all.

Affected fields include (but aren’t limited to):

  • Boolean flags: e.g. AppClear, TelemetryEnabled, AutoUpdateEnabled
  • Numeric values: e.g. AiMaxTokens, EditorFontSize, AutoUpdateIntervalMs
  • Pointer types: e.g. TermScrollback *int64, TermTransparency *float64, WindowTileGapSize *int64

Recommendations:

  • Document that $ENV: substitutions currently only work for string‐typed settings.
  • Optionally extend resolveEnvValue (or post‐unmarshal logic) to parse the resolved string into the target Go type—e.g. using strconv.ParseBool, strconv.ParseInt, strconv.ParseFloat—before calling json.Unmarshal.
  • Alternatively, introduce typed placeholders like $ENV:VAR|int or $ENV:VAR|bool and handle those in resolveEnvValue.

Let me know if you’d like help drafting the conversion logic or updating the documentation in a follow-up PR.

📜 Review details

Configuration used: CodeRabbit UI

Review profile: CHILL

Plan: Pro

💡 Knowledge Base configuration:

  • MCP integration is disabled by default for public repositories
  • Jira integration is disabled by default for public repositories
  • Linear integration is disabled by default for public repositories

You can enable these sources in your CodeRabbit configuration.

📥 Commits

Reviewing files that changed from the base of the PR and between 56f0389 and d75d5fc.

📒 Files selected for processing (1)
  • pkg/wconfig/settingsconfig.go (2 hunks)
🧰 Additional context used
🧬 Code graph analysis (1)
pkg/wconfig/settingsconfig.go (1)
pkg/waveobj/metamap.go (1)
  • MetaMapType (8-8)
⏰ 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). (3)
  • GitHub Check: Analyze (javascript-typescript)
  • GitHub Check: Analyze (go)
  • GitHub Check: Build for TestDriver.ai

Comment on lines 364 to 387
func resolveEnvValue(value string) (string, bool) {
if !strings.HasPrefix(value, "$ENV:") {
return "", false
}

envSpec := value[5:] // Remove "$ENV:" prefix
parts := strings.SplitN(envSpec, ":", 2)
envVar := parts[0]
var fallback string
if len(parts) > 1 {
fallback = parts[1]
}

// Get the environment variable value
if envValue := os.Getenv(envVar); envValue != "" {
return envValue, true
}

// Return fallback if provided, otherwise return empty string
if fallback != "" {
return fallback, true
}
return "", true
}
Copy link
Contributor

Choose a reason for hiding this comment

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

🛠️ Refactor suggestion

Use os.LookupEnv to distinguish “unset” vs “set to empty string”; optionally trim whitespace

With os.Getenv you can’t tell whether a variable is unset or explicitly set to an empty string. Current logic treats empty as “unset” and prefers the fallback, which is surprising if users deliberately export VAR="". Using os.LookupEnv preserves the conventional semantics: if it’s set (even to empty), prefer the env over the fallback. Trimming whitespace around the parsed parts also avoids accidental spaces in JSON.

-func resolveEnvValue(value string) (string, bool) {
+func resolveEnvValue(value string) (string, bool) {
   if !strings.HasPrefix(value, "$ENV:") {
     return "", false
   }
 
-  envSpec := value[5:] // Remove "$ENV:" prefix
-  parts := strings.SplitN(envSpec, ":", 2)
-  envVar := parts[0]
+  envSpec := value[5:] // Remove "$ENV:" prefix
+  parts := strings.SplitN(envSpec, ":", 2)
+  envVar := strings.TrimSpace(parts[0])
   var fallback string
   if len(parts) > 1 {
-    fallback = parts[1]
+    fallback = strings.TrimSpace(parts[1])
   }
 
   // Get the environment variable value
-  if envValue := os.Getenv(envVar); envValue != "" {
-    return envValue, true
-  }
+  if envValue, exists := os.LookupEnv(envVar); exists {
+    return envValue, true // prefer the env value even if it's an empty string
+  }
 
   // Return fallback if provided, otherwise return empty string
   if fallback != "" {
     return fallback, true
   }
   return "", true
 }

If you prefer the old behavior (fallback wins over empty env), keep Getenv but please document it explicitly as it’s non-standard.

📝 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
func resolveEnvValue(value string) (string, bool) {
if !strings.HasPrefix(value, "$ENV:") {
return "", false
}
envSpec := value[5:] // Remove "$ENV:" prefix
parts := strings.SplitN(envSpec, ":", 2)
envVar := parts[0]
var fallback string
if len(parts) > 1 {
fallback = parts[1]
}
// Get the environment variable value
if envValue := os.Getenv(envVar); envValue != "" {
return envValue, true
}
// Return fallback if provided, otherwise return empty string
if fallback != "" {
return fallback, true
}
return "", true
}
func resolveEnvValue(value string) (string, bool) {
if !strings.HasPrefix(value, "$ENV:") {
return "", false
}
envSpec := value[5:] // Remove "$ENV:" prefix
parts := strings.SplitN(envSpec, ":", 2)
envVar := strings.TrimSpace(parts[0])
var fallback string
if len(parts) > 1 {
fallback = strings.TrimSpace(parts[1])
}
// Get the environment variable value
if envValue, exists := os.LookupEnv(envVar); exists {
return envValue, true // prefer the env value even if it's an empty string
}
// Return fallback if provided, otherwise return empty string
if fallback != "" {
return fallback, true
}
return "", true
}
🤖 Prompt for AI Agents
In pkg/wconfig/settingsconfig.go around lines 364-387, replace os.Getenv with
os.LookupEnv and trim whitespace on parsed parts so you can tell the difference
between an env var that is unset versus set to an empty string and avoid
accidental spaces: parse envSpec, strings.TrimSpace on envVar and fallback, call
os.LookupEnv(envVar) and if found (even empty) return that value with true; if
not found and fallback != "" return trimmed fallback with true; otherwise return
"" and true (preserving the function's resolved flag semantics).

@sawka sawka merged commit 07bd6c5 into main Aug 26, 2025
7 of 8 checks passed
@sawka sawka deleted the sawka/config-env branch August 26, 2025 23:56
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.

1 participant