metacpan-api
metacpan-api copied to clipboard
Non existing URL results in Crash - 500 Internal Server Error
Sending a non existing URL to the server produces an Crash in the Application and results in an Internal Server Error - Status Code 500
$ wget -S -O - https://fastapi.metacpan.org/v1/file/_search?path=Data.pm
--2021-07-08 11:36:53-- https://fastapi.metacpan.org/v1/file/_search?path=Data.pm
Resolviendo fastapi.metacpan.org (fastapi.metacpan.org)... 151.101.134.217, 2a04:4e42:1f::729
Conectando con fastapi.metacpan.org (fastapi.metacpan.org)[151.101.134.217]:443... conectado.
Petición HTTP enviada, esperando respuesta...
HTTP/1.1 500 Internal Server Error
Connection: keep-alive
Content-Length: 315
Server: nginx
Content-Type: application/json; charset=utf-8
Cache-Control: private
Fastly-Restarts: 1
Accept-Ranges: bytes
Date: Thu, 08 Jul 2021 10:36:53 GMT
Via: 1.1 varnish
X-Served-By: cache-mad22053-MAD
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1625740614.662722,VS0,VE253
2021-07-08 11:36:53 ERROR 500: Internal Server Error.
in the Browser you can see:
{
"message" : "[Param] ** Unknown param (index) in (search) request. See docs at: http://www.elastic.co/guide/en/elasticsearch/reference/current/search-search.html, called from sub Search::Elasticsearch::Role::Client::Direct::__ANON__ at /home/metacpan/metacpan-api/lib/MetaCPAN/Server/Controller.pm line 122."
}
When searching a file by this Total Path like File/Data.pm produces a Crash in the Application with Internal Server Error - Status Code 500:
$ wget -S -O - https://fastapi.metacpan.org/v1/file/_search?q=File/Data.pm
--2021-07-08 11:44:02-- https://fastapi.metacpan.org/v1/file/_search?q=File/Data.pm
Resolviendo fastapi.metacpan.org (fastapi.metacpan.org)... 151.101.134.217, 2a04:4e42:1f::729
Conectando con fastapi.metacpan.org (fastapi.metacpan.org)[151.101.134.217]:443... conectado.
Petición HTTP enviada, esperando respuesta...
HTTP/1.1 500 Internal Server Error
Connection: keep-alive
Content-Length: 1419
Server: nginx
Content-Type: application/json; charset=utf-8
Cache-Control: private
Fastly-Restarts: 1
Accept-Ranges: bytes
Date: Thu, 08 Jul 2021 10:44:02 GMT
Via: 1.1 varnish
X-Served-By: cache-mad22065-MAD
X-Cache: MISS
X-Cache-Hits: 0
X-Timer: S1625741043.719754,VS0,VE276
2021-07-08 11:44:03 ERROR 500: Internal Server Error.
in the Browser you can see:
{
"message" : "[Request] ** [http://127.0.0.1:9200]-[400] [query_parsing_exception] Failed to parse query [file/Data.pm], with: {\"index\":\"cpan_v1_01\"}, called from sub Search::Elasticsearch::Role::Client::Direct::__ANON__ at /home/metacpan/metacpan-api/lib/MetaCPAN/Server/Controller.pm line 122. With vars: {'request' => {'method' => 'GET','body' => undef,'serialize' => 'std','path' => '/cpan/file/_search','qs' => {'q' => 'file/Data.pm'},'ignore' => []},'status_code' => 400,'body' => {'status' => 400,'error' => {'phase' => 'query','reason' => 'all shards failed','grouped' => bless( do{\\(my $o = 1)}, 'JSON::PP::Boolean' ),'root_cause' => [{'type' => 'query_parsing_exception','reason' => 'Failed to parse query [file/Data.pm]','index' => 'cpan_v1_01'}],'type' => 'search_phase_execution_exception','failed_shards' => [{'node' => '22-yA8_3SUi3u08N540zuw','shard' => 0,'index' => 'cpan_v1_01','reason' => {'type' => 'query_parsing_exception','reason' => 'Failed to parse query [file/Data.pm]','caused_by' => {'type' => 'parse_exception','caused_by' => {'reason' => 'Lexical error at line 1, column 13. Encountered: <EOF> after : \"/Data.pm\"','type' => 'token_mgr_error'},'reason' => 'Cannot parse \\'file/Data.pm\\': Lexical error at line 1, column 13. Encountered: <EOF> after : \"/Data.pm\"'},'index' => 'cpan_v1_01'}}]}}}\n"
}
If the Request q=File/Data.pm was not permitted the expected behaviour would be to return an Error Response Bad Request - Status Code 400