Skip to content

/clear fails with status code 500 when clearing an empty bg

Steps to reproduce

  • start the server
  • place a POST request without payload at /clear

Can also be reproduced by first adding something to the bg and then clearing that twice.

Expected behavior Fail gracefully, that is return 2xx status code.

Observed behavior Server returns 500 Internal Server Error

Error trace in PROLOG

% [Thread httpd@4444_2] POST /clear: [500] goal unexpectedly failed: web_api:clear_bg([protocol(http),peer(ip(127,0,0,1)),pool(client('httpd@4444',web_api:http_dispatch,<stream>(0x7ff06c01a8e0),<stream>(0x7ff06c01aa70))),input(<stream>(0x7ff06c01a8e0)),method(post),request_uri('/clear'),path('/clear'),http_version(1-1),content_type('application/json'),user_agent('PostmanRuntime/7.26.5'),accept([media(_752/_754,[],1.0,[])]),postman_token('5eb7687c-b1e3-40d9-aa30-7b29f18623c3'),host(localhost),port(4444),accept_encoding('gzip, deflate, br'),connection('keep-alive'),content_length(434)])
In:
  [19] throw(error(goal_failed(...),_864))
  [18] http_dispatch:call_action(web_api:clear_bg,[protocol(http),...|...]) at /usr/lib/swi-prolog/library/http/http_dispatch.pl:772
  [16] time:run_alarm_goal('<garbage_collected>','<garbage_collected>') at /usr/lib/swi-prolog/library/time.pl:145
  [15] setup_call_catcher_cleanup(time:alarm(300,...,...,...),time:run_alarm_goal(...,...),_982,time:remove_alarm_notrace(...)) at /usr/lib/swi-prolog/boot/init.pl:443
  [13] time:call_with_time_limit(300,'<garbage_collected>') at /usr/lib/swi-prolog/library/time.pl:136
   [8] httpd_wrapper:call_handler('<garbage_collected>',1,'<garbage_collected>') at /usr/lib/swi-prolog/library/http/http_wrapper.pl:320
   [7] catch(httpd_wrapper:call_handler(...,1,...),error(goal_failed(...),context(_1144,_1146)),httpd_wrapper:true) at /usr/lib/swi-prolog/boot/init.pl:371
   [6] httpd_wrapper:handler_with_output_to(web_api:http_dispatch,1,'<garbage_collected>',current_output,error(goal_failed(...),context(_1210,_1212))) at /usr/lib/swi-prolog/library/http/http_wrapper.pl:297
   [5] httpd_wrapper:handler_with_output_to('<garbage_collected>',1,'<garbage_collected>',<stream>(0x7ff06c01fd10),error(goal_failed(...),context(_1264,_1266))) at /usr/lib/swi-prolog/library/http/http_wrapper.pl:309
   [4] httpd_wrapper:http_wrapper('<garbage_collected>',<stream>(0x7ff06c01a8e0),<stream>(0x7ff06c01aa70),_1302,'<garbage_collected>') at /usr/lib/swi-prolog/library/http/http_wrapper.pl:98
   [3] thread_httpd:http_process('<garbage_collected>',<stream>(0x7ff06c01a8e0),<stream>(0x7ff06c01aa70),'<garbage_collected>') at /usr/lib/swi-prolog/library/http/thread_httpd.pl:778
   [2] catch(thread_httpd:http_process(...,<stream>(0x7ff06c01a8e0),<stream>(0x7ff06c01aa70),...),_1366,thread_httpd:true) at /usr/lib/swi-prolog/boot/init.pl:371
   [1] thread_httpd:http_worker([queue('httpd@4444'),...|...]) at /usr/lib/swi-prolog/library/http/thread_httpd.pl:554
   [0] <meta call>

Note: some frames are missing due to last-call optimization.
Re-run your program in debug mode (:- debug.) to get more detail.