[jira] [Updated] (SOLR-8836) /update should return BAD REQUEST when invalid JSON provided
[ https://issues.apache.org/jira/browse/SOLR-8836?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Jason Gerlowski updated SOLR-8836: -- Attachment: SOLR-8836.patch A simple patch demonstrating a fix for the issue. With this fix, /update answers invalid JSON with the response: {code} [~/c/s/l/solr] $ curl -i -l -k -X POST -H 'Content-Type: application/json' 'http://localhost:7574/solr/gettingstarted/update' --data-binary '}{' HTTP/1.1 400 Bad Request {"responseHeader":{"status":400,"QTime":11},"error":{"metadata":["error-class","org.apache.solr.common.SolrException","root-error-class","org.noggit.JSONParser$ParseException"],"msg":"org.noggit.JSONParser$ParseException: JSON Parse Error: char=},position=0 BEFORE='}' AFTER='{'","code":400}} {code} This fixes the status code, but the response body is a little odd. I'm not quite sure where the "metadata", "error-class", "root-error-class" nesting comes from. Still some details of Solr's error reporting that I'm brushing up on; bit of a work-in-progress. > /update should return BAD REQUEST when invalid JSON provided > > > Key: SOLR-8836 > URL: https://issues.apache.org/jira/browse/SOLR-8836 > Project: Solr > Issue Type: Bug >Affects Versions: master >Reporter: Jason Gerlowski >Priority: Trivial > Fix For: master > > Attachments: SOLR-8836.patch > > > When a user provides invalid JSON to the /update endpoint, the request fails > with a 500 (INTERNAL SERVER ERROR). If the user looks at the response body, > they'll see a message indicating that the provided JSON was invalid. > However, going from the status code alone, the failure is indistinguishable > from a true server-error. This is a bit misleading. It would be nice if > Solr instead returned a 400 (BAD REQUEST) status code when it detects invalid > arguments. > Reproduction Steps: > 1.) bin/solr start -e cloud -noprompt > 2.) curl -i -l -k -X POST -H 'Content-Type: application/json' > 'http://localhost:8983/solr/gettingstarted/update' --data-binary '}{' -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org
[jira] [Updated] (SOLR-8836) /update should return BAD REQUEST when invalid JSON provided
[ https://issues.apache.org/jira/browse/SOLR-8836?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Jason Gerlowski updated SOLR-8836: -- Attachment: SOLR-8836.patch Looking into Solr's error messages more, I think the error-message is pretty standard when SolrException is used. So I'm fine with it now. Latest patch adds a test, which ensures 400 is returned. All tests pass locally. Patch should be ready for review if anyone has interest in seeing this change get in. > /update should return BAD REQUEST when invalid JSON provided > > > Key: SOLR-8836 > URL: https://issues.apache.org/jira/browse/SOLR-8836 > Project: Solr > Issue Type: Bug >Affects Versions: master >Reporter: Jason Gerlowski >Priority: Trivial > Fix For: master > > Attachments: SOLR-8836.patch, SOLR-8836.patch > > > When a user provides invalid JSON to the /update endpoint, the request fails > with a 500 (INTERNAL SERVER ERROR). If the user looks at the response body, > they'll see a message indicating that the provided JSON was invalid. > However, going from the status code alone, the failure is indistinguishable > from a true server-error. This is a bit misleading. It would be nice if > Solr instead returned a 400 (BAD REQUEST) status code when it detects invalid > arguments. > Reproduction Steps: > 1.) bin/solr start -e cloud -noprompt > 2.) curl -i -l -k -X POST -H 'Content-Type: application/json' > 'http://localhost:8983/solr/gettingstarted/update' --data-binary '}{' -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org
[jira] [Updated] (SOLR-8836) /update should return BAD REQUEST when invalid JSON provided
[ https://issues.apache.org/jira/browse/SOLR-8836?page=com.atlassian.jira.plugin.system.issuetabpanels:all-tabpanel ] Anshum Gupta updated SOLR-8836: --- Fix Version/s: 6.0 > /update should return BAD REQUEST when invalid JSON provided > > > Key: SOLR-8836 > URL: https://issues.apache.org/jira/browse/SOLR-8836 > Project: Solr > Issue Type: Bug >Affects Versions: master >Reporter: Jason Gerlowski >Assignee: Anshum Gupta >Priority: Trivial > Fix For: master, 6.0 > > Attachments: SOLR-8836.patch, SOLR-8836.patch > > > When a user provides invalid JSON to the /update endpoint, the request fails > with a 500 (INTERNAL SERVER ERROR). If the user looks at the response body, > they'll see a message indicating that the provided JSON was invalid. > However, going from the status code alone, the failure is indistinguishable > from a true server-error. This is a bit misleading. It would be nice if > Solr instead returned a 400 (BAD REQUEST) status code when it detects invalid > arguments. > Reproduction Steps: > 1.) bin/solr start -e cloud -noprompt > 2.) curl -i -l -k -X POST -H 'Content-Type: application/json' > 'http://localhost:8983/solr/gettingstarted/update' --data-binary '}{' -- This message was sent by Atlassian JIRA (v6.3.4#6332) - To unsubscribe, e-mail: dev-unsubscr...@lucene.apache.org For additional commands, e-mail: dev-h...@lucene.apache.org