diff --git a/paperprocessor.go b/paperprocessor.go index 686521f..31527b8 100644 --- a/paperprocessor.go +++ b/paperprocessor.go @@ -6,6 +6,7 @@ import ( "fmt" "io/ioutil" "net/http" + "strings" "time" ) @@ -184,7 +185,15 @@ Abstract: %s`, criteria, paper.Title, paper.Abstract) return nil, fmt.Errorf("invalid response format") } - decision := string(bytes.TrimSpace(lines[0])) + decisionParts := bytes.SplitN(lines[0], []byte(":"), 2) + if len(decisionParts) != 2 { + return nil, fmt.Errorf("invalid decision format, expected 'DECISION: [VALUE]'") + } + decision := strings.ToUpper(string(bytes.TrimSpace(decisionParts[1]))) + if decision != "ACCEPT" && decision != "REJECT" { + return nil, fmt.Errorf("invalid decision value: %s", decision) + } + explanation := string(bytes.TrimSpace(bytes.Join(lines[1:], []byte("\n")))) return &decisionResult{