Skip to content

feat: api key prefix config, close #1475#1502

Merged
looplj merged 1 commit into
unstablefrom
dev-tmp
Apr 26, 2026
Merged

feat: api key prefix config, close #1475#1502
looplj merged 1 commit into
unstablefrom
dev-tmp

Conversation

@looplj

@looplj looplj commented Apr 26, 2026

Copy link
Copy Markdown
Owner

@greptile-apps greptile-apps Bot left a comment

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.

Your free trial has ended. If you'd like to continue receiving code reviews, you can add a payment method here.

@devin-ai-integration devin-ai-integration Bot left a comment

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.

✅ Devin Review: No Issues Found

Devin Review analyzed this PR and found no potential bugs to report.

View in Devin Review to see 3 additional findings.

Open in Devin Review

@looplj looplj merged commit 65eb778 into unstable Apr 26, 2026
5 checks passed

@gemini-code-assist gemini-code-assist Bot left a comment

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.

Code Review

This pull request introduces a configurable API key prefix, replacing the hardcoded "ah-" prefix. Changes include updates to the configuration structures, default settings, and the APIKeyService to support a custom prefix during key generation. A review comment suggests improving the prefix handling in GenerateAPIKey to avoid leading or double hyphens when the prefix is empty or already contains a trailing hyphen.

// Convert to hex and add ah- prefix
return "ah-" + hex.EncodeToString(bytes), nil
// Convert to hex and add prefix
return prefix + "-" + hex.EncodeToString(bytes), nil

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.

medium

The current implementation unconditionally adds a hyphen between the prefix and the random hex string. If the prefix is empty, the generated key will start with a leading hyphen (e.g., -<hex>). Additionally, if the configured prefix already ends with a hyphen (e.g., ah-), the resulting key will contain a double hyphen (e.g., ah--<hex>). It is better to handle these cases gracefully.

Suggested change
return prefix + "-" + hex.EncodeToString(bytes), nil
prefix = strings.TrimSpace(prefix)
if prefix == "" {
return hex.EncodeToString(bytes), nil
}
return strings.TrimSuffix(prefix, "-") + "-" + hex.EncodeToString(bytes), nil

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