API Error: config is too long - JSON bool values not sent correctly - 400 bad request on PATCH requests
See original GitHub issueEnvironment:
- CTFd Version/Commit: 3.3.0 (
ctfd/ctfd:latest
image) - Operating System: Docker on AWS ECS
- Web Browser and Version: Mozilla/5.0 (Macintosh; Intel Mac OS X 10.14; rv:89.0) Gecko/20100101 Firefox/89.0
What happened? Send the following request:
curl 'https://host/api/v1/configs' -X PATCH -H 'User-Agent: Mozilla/5.0
(Macintosh; Intel Mac OS X 10.14; rv:89.0) Gecko/20100101 Firefox/89.0' -H
'Accept: application/json' -H 'Accept-Language: en-US,en;q=0.5' --compressed -H
'Referer: https://host/admin/config' -H 'Content-Type: application/json' -H
'CSRF-Token: ****************************************************' -H 'Origin:
https://host' -H 'DNT: 1' -H 'Connection: keep-alive' -H 'Cookie:
session=******-******-**************' -H 'Sec-GPC: 1' -H 'TE: Trailers'
--data-raw $'{"successful_registration_email_subject":"Successfully registered
for {ctf_name}","successful_registration_email_body":"You\'ve successfully
registered for {ctf_name}\041","verification_email_subject":"Confirm your
account for {ctf_name}","verification_email_body":"Welcome to
{ctf_name}\041\\r\\n\\r\\nClick the following link to confirm and activate
your account:\\r\\n{url}\\r\\n\\r\\nIf the link is not clickable, try
copying and pasting it into your
browser.","user_creation_email_subject":"Message from
{ctf_name}","user_creation_email_body":"A new account has been created for
you for {ctf_name} at {url}. \\r\\n\\r\\nUsername: {name}\\r\\nPassword:
{password}","password_reset_subject":"Password Reset Request from
{ctf_name}","password_reset_body":"Did you initiate a password reset on
{ctf_name}? If you didn\'t initiate this request you can ignore this email.
\\r\\n\\r\\nClick the following link to reset your
password:\\r\\n{url}\\r\\n\\r\\nIf the link is not clickable, try copying
and pasting it into your
browser.","password_change_alert_subject":"Password Change Confirmation for
{ctf_name}","password_change_alert_body":"Your password for {ctf_name} has
been changed.\\r\\n\\r\\nIf you didn\'t request a password change you can
reset your password here:
{url}","mailfrom_addr":"","mail_server":"","mail_port":"","mail_username":null,
"mail_password":null,"mailgun_base_url":"","mailgun_api_key":"",
"mail_useauth":false,"mail_ssl":false,"mail_tls":false}'
gives a 400 bad request status with the following body
{"success": false, "errors": {"value": ["mail_useauth config is too long"]}}
while if I change the false
values in the JSON to "false"
(with quotes), I get the expected 200 OK status.
What did you expect to happen?
{"success": true
How to reproduce your issue Use Firefox’s integrated developer tools to copy the request as cURL and used cURL to send it again.
Any associated stack traces or error logs
./CTFd/themes/core/assets/js/fetch.js/t.default
https://host/themes/admin/static/js/pages/configs.min.js:1:62180
./CTFd/themes/core/assets/js/api.js/n</e.prototype.request
https://host/themes/admin/static/js/pages/configs.min.js:1:26970
./CTFd/themes/core/assets/js/patch.js/o.API.prototype.patch_config_list
https://host/themes/admin/static/js/pages/configs.min.js:1:65384
v
https://host/themes/admin/static/js/pages/configs.min.js:1:4002
dispatch
https://host/themes/admin/static/js/vendor.bundle.min.js:110:39033
add/h.handle
https://host/themes/admin/static/js/vendor.bundle.min.js:110:37028
Issue Analytics
- State:
- Created 2 years ago
- Comments:6 (2 by maintainers)
Top Results From Across the Web
Patching to TFS API with JSON gives 400 error (Bad Request)
A 400 means that the request was malformed. In other words, the data stream sent by the client to the server didn't follow...
Read more >API 400 Bad Request during PATCH Request - Google Groups
My nginx access logs shows that all PATCH, PUT and DELETE request ends with error 400. gunicorn. stderr. log doesn't give anything useful...
Read more >Solved: 400: Bad Request : The request could not be comple...
I have given all the required tags as per API Doc. However geting the error "The request could not be completed due to...
Read more >HTTP status and error codes for JSON | Cloud Storage
An HTTP status code value, without the textual description. Example values include: 400 (Bad Request), 401 (Unauthorized), and 404 (Not Found).
Read more >Microsoft Graph error responses and resource types
HTTP status codes ; 400, Bad Request, Cannot process the request because it is malformed or incorrect. ; 401, Unauthorized, Required ...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Meanwhile I’ve tested this patch, which seems to be doing the job:
This should be fixed now, if not please comment or open a new issue.