fix: address PR #62 review findings
CI / test (pull_request) Successful in 16s
CI / review (anthropic--claude-4.6-sonnet, sonnet, SONNET_REVIEW_TOKEN) (pull_request) Successful in 27s
CI / review (gpt-5, gpt, GPT_REVIEW_TOKEN) (pull_request) Successful in 1m5s
CI / review (gpt-5, security, SECURITY_REVIEW.md, SECURITY_REVIEW_TOKEN) (pull_request) Successful in 1m40s
CI / test (pull_request) Successful in 16s
CI / review (anthropic--claude-4.6-sonnet, sonnet, SONNET_REVIEW_TOKEN) (pull_request) Successful in 27s
CI / review (gpt-5, gpt, GPT_REVIEW_TOKEN) (pull_request) Successful in 1m5s
CI / review (gpt-5, security, SECURITY_REVIEW.md, SECURITY_REVIEW_TOKEN) (pull_request) Successful in 1m40s
- Remove duplicate flag.Parse() call - Fix nil map panic in LoadRemotePersonas error path by assigning empty map when LoadRemotePersonas returns an error - Tighten isNotFoundError to only check HTTP 404 (remove broad 'not found' substring check to avoid false positives) - Clean up personaErr variable scope using narrower-scoped err variables - Add proper doc comment to LoadRemotePersonasFromPath (Go convention) - Add file count cap (50 files) in LoadRemotePersonasFromPath to prevent resource exhaustion from repos with thousands of small files - Update test expectation for tightened isNotFoundError
This commit is contained in:
+10
-8
@@ -79,7 +79,6 @@ func main() {
|
||||
aicoreAPIURL := flag.String("aicore-api-url", envOrDefault("AICORE_API_URL", ""), "SAP AI Core API URL (for provider=aicore)")
|
||||
aicoreResourceGroup := flag.String("aicore-resource-group", envOrDefault("AICORE_RESOURCE_GROUP", "default"), "SAP AI Core resource group (for provider=aicore)")
|
||||
|
||||
flag.Parse()
|
||||
flag.Parse()
|
||||
|
||||
if *versionFlag {
|
||||
@@ -119,7 +118,6 @@ func main() {
|
||||
// Persona loading is deferred until after giteaClient is initialized,
|
||||
// so we can try loading from the target repo first.
|
||||
var persona *review.Persona
|
||||
var personaErr error
|
||||
|
||||
// Validate reviewer-name: only safe characters allowed in sentinel
|
||||
if err := validateReviewerName(*reviewerName); err != nil {
|
||||
@@ -184,6 +182,8 @@ func main() {
|
||||
remotePersonas, err := review.LoadRemotePersonas(ctx, fetcher, owner, repoName)
|
||||
if err != nil {
|
||||
slog.Warn("could not load remote personas", "repo", fmt.Sprintf("%s/%s", owner, repoName), "error", err)
|
||||
// Assign empty map so the lookup below doesn't panic
|
||||
remotePersonas = map[string]*review.Persona{}
|
||||
}
|
||||
|
||||
if p, ok := remotePersonas[*personaName]; ok {
|
||||
@@ -191,9 +191,10 @@ func main() {
|
||||
slog.Info("loaded persona from target repo", "persona", persona.Name, "display", persona.DisplayName)
|
||||
} else {
|
||||
// Fall back to built-in persona
|
||||
persona, personaErr = review.LoadBuiltinPersona(*personaName)
|
||||
if personaErr != nil {
|
||||
slog.Error("failed to load persona", "persona", *personaName, "error", personaErr)
|
||||
var err error
|
||||
persona, err = review.LoadBuiltinPersona(*personaName)
|
||||
if err != nil {
|
||||
slog.Error("failed to load persona", "persona", *personaName, "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
slog.Info("loaded built-in persona", "persona", persona.Name, "display", persona.DisplayName)
|
||||
@@ -204,9 +205,10 @@ func main() {
|
||||
slog.Error("invalid persona-file path", "error", err)
|
||||
os.Exit(1)
|
||||
}
|
||||
persona, personaErr = review.LoadPersona(resolvedPath)
|
||||
if personaErr != nil {
|
||||
slog.Error("failed to load persona file", "file", *personaFile, "error", personaErr)
|
||||
var err2 error
|
||||
persona, err2 = review.LoadPersona(resolvedPath)
|
||||
if err2 != nil {
|
||||
slog.Error("failed to load persona file", "file", *personaFile, "error", err2)
|
||||
os.Exit(1)
|
||||
}
|
||||
slog.Info("loaded persona from file", "file", *personaFile, "persona", persona.Name)
|
||||
|
||||
Reference in New Issue
Block a user