Conversation
WalkthroughThe Changes
Poem
✨ Finishing Touches
🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
SupportNeed help? Create a ticket on our support page for assistance with any issues or questions. Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Nitpick comments (1)
internal/project/project.go (1)
401-412: Consider extracting the hardcoded prefix to a constant and improving variable naming.The filtering logic is correct and achieves the intended security goal. However, there are some improvements that could enhance maintainability:
- The prefix "AGENTUITY_" is hardcoded and duplicated
- Variable names
_envand_secretsare not descriptive- The filtering logic is duplicated between env and secrets
Consider this refactor for better maintainability:
+const internalEnvPrefix = "AGENTUITY_" + +func filterInternalKeys(input map[string]string) map[string]string { + filtered := make(map[string]string) + for k, v := range input { + if !strings.HasPrefix(k, internalEnvPrefix) { + filtered[k] = v + } + } + return filtered +} + func (p *Project) SetProjectEnv(ctx context.Context, logger logger.Logger, baseUrl string, token string, env map[string]string, secrets map[string]string) (*ProjectData, error) { client := util.NewAPIClient(ctx, logger, baseUrl, token) var projectResponse ProjectResponse - _env := make(map[string]string) - for k, v := range env { - if !strings.HasPrefix(k, "AGENTUITY_") { - _env[k] = v - } - } - _secrets := make(map[string]string) - for k, v := range secrets { - if !strings.HasPrefix(k, "AGENTUITY_") { - _secrets[k] = v - } - } + filteredEnv := filterInternalKeys(env) + filteredSecrets := filterInternalKeys(secrets)
📜 Review details
Configuration used: CodeRabbit UI
Review profile: CHILL
Plan: Pro
📒 Files selected for processing (1)
internal/project/project.go(1 hunks)
🔇 Additional comments (1)
internal/project/project.go (1)
414-415: Approve the use of filtered maps in API payload.The filtered maps are correctly used in the API call, ensuring that internal environment variables and secrets are not exposed to external systems.
Summary by CodeRabbit