Skip to content

Commit 540fb5e

Browse files
authored
Change GeneralScriptException to 400 (#133659)
Errors in scripts are generally due to user errors in the script itself. ScriptException has a 400 status code reflecting that fact, but GeneralScriptException uses the default 500 status code. This commit fixes GeneralScriptException to match the 400 status code of other scripting errors.
1 parent 1023131 commit 540fb5e

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

docs/changelog/133659.yaml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
pr: 133659
2+
summary: Fixed GeneralScriptException to return 400 http status code
3+
area: Infra/Scripting
4+
type: bug
5+
issues: []

server/src/main/java/org/elasticsearch/script/GeneralScriptException.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@
1111

1212
import org.elasticsearch.ElasticsearchException;
1313
import org.elasticsearch.common.io.stream.StreamInput;
14+
import org.elasticsearch.rest.RestStatus;
1415

1516
import java.io.IOException;
1617

@@ -38,4 +39,8 @@ public GeneralScriptException(String msg, Throwable cause) {
3839
public GeneralScriptException(StreamInput in) throws IOException {
3940
super(in);
4041
}
42+
43+
public RestStatus status() {
44+
return RestStatus.BAD_REQUEST;
45+
}
4146
}

0 commit comments

Comments
 (0)