Uncaught ajax.js error / exception

Created on 20 December 2023, 12 months ago
Updated 12 September 2024, 3 months ago

Problem/Motivation

When adding fields of type "Reference" and some other types to a content type, the message "Oops, something went wrong. Check your browser's developer console for more details." is generated, with an accompanying "Uncaught" exception in the console.

  • Windows 11
  • WAMP server running Apache 2.4.57.3, PHP 8.2.13, MySQL 8.0.32
  • Drupal 10.2.0
  • Firefox and Edge as the browser, both showing same behaviour.

Steps to reproduce

Create a new content type A. Create a taxonomy / vocabulary B. Create another content type C. Add a reference field to content type C of type Content. Attempt to pick content type A as the referring type. Error generated.

Add another reference field to content type C of type Taxonomy. Attempt to pick vocabulary B. Error generated.

The error also seems to be generated when attempting to change the display of the label from "Above" to "Inline" after having added a number of fields to content type C:

Uncaught 
Object { message: '\nAn AJAX HTTP error occurred.\nHTTP Result Code: 200\nDebugging information follows.\nPath: /admin/structure/types/manage/project/display?ajax_form=1\nStatusText: OK\nResponseText: [{"command":"settings","settings":{"ajaxPageState":{"theme":"claro","theme_token":"gNBkdUwZ3Dm97PoEDNJJoWphmNujk2zamwW_Vi1zy6U","libraries":"eJx9UkFywyAM_BDGb-hLPDIojlIsUQGepK8vTow7TtJeYLW7Gi2MwM_EQxYJI2i_3TYrooE_JXuWBZU4I-ej7X6n3UxO2ACzFHY4V3caToi-91oiBPuq2K3TjDQNkSL2DRgXQKV1MixdhjFt7BRkhNClfAvEk6lTM15zgdD8v0xXHZ_pf0sL4URxz-oyLXjvPvBOQoCY8EDWaAG9wvSetXCB66ukmKJwqmMe2vrBylW9fBXUmz2Jzg-FK4JA32g8LlifsJ57bOSFVHj91YHYk4Ms2ia9Fc2JMPhhUimxf-BCpoHWugvpLJpdyU1otXlalufaYnIQ8WPdGFMS7qFWfF-W9ANoHABw"},"fieldUIRowsData":{"field-client":{"rowHandler":"field","defaultPlugin":"entity_reference_label","name":"field_client","region":"content"},"field-client-rfx-number":{"rowHandler":"field","defaultPlugin":"string","name":"field_client_rfx_number","region":"content"},"field-description":{"rowHandler":"field","defaultPlugin":"textโ€ฆ', name: "AjaxError", stack: "@http://rp10.local/core/misc/ajax.js?v=10.2.0:196:32\n@http://rp10.local/core/misc/ajax.js?v=10.2.0:1915:3\n" }

Going back to add a new field. Attempted to add a Reference field. As soon as I clicked the radio button, error:

Uncaught 
Object { message: '\nAn AJAX HTTP error occurred.\nHTTP Result Code: 200\nDebugging information follows.\nPath: /admin/structure/types/manage/project/fields/add-field?ajax_form=1\nStatusText: OK\nResponseText: [{"command":"update_build_id","old":"form-AH1mp4QXqU3cjjrjzp4nYqgnBnxM3T8IpHXWBR7t99c","new":"form-NCqER1WPUgYCoXCqXqSDvo5kCCLxd_PCo-3VPafQolc"},{"command":"insert","method":null,"selector":null,"data":"\\u003Cdiv id=\\u0022group-field-options-wrapper\\u0022 class=\\u0022group-field-options-wrapper\\u0022\\u003E\\u003Clabel data-drupal-selector=\\u0022edit-label\\u0022 for=\\u0022edit-label--zUHmO2HZw88\\u0022 class=\\u0022form-item__label js-form-required form-required\\u0022\\u003EChoose an option below\\u003C\\/label\\u003E\\u003Cdiv class=\\u0022group-field-options js-form-wrapper form-wrapper\\u0022 data-drupal-selector=\\u0022edit-fields\\u0022 id=\\u0022edit-fields--8DH0tjsuWA0\\u0022\\u003E\\u003Cdiv class=\\u0022js-click-to-select subfield-option field-suboption__item\\u0022\\u003E\\n    \\u003Cinput class=\\u0022field-option-radio form-radio form-boolean form-boolean--type-radio\\u0022 data-once=\\u0022field-click-to-select\\u0022 data-drupal-selector=\\u0022field-uientity-referencenode\\u0022 aria-describedby=\\u0022field_ui:entity_reference:node--description\\u0022 type=\\u0022radio\\u0022 id=\\u0022field_ui:entity_reference:node\\u0022 name=\\u0022group_field_options_wrapper\\u0022 value=\\u0022field_ui:entity_reference:node\\u0022\\/\\u003E\\n      \\u003Clabel for=\\u0022field_ui:entity_reference:node\\u0022 class=\\u0022form-item__label option\\u0022\\u003EContent\\u003C\\/label\\u003E\\n    \\u003Cdiv id=\\u0022field_ui:entity_reference:node--description\\u0022\\u003E\\n      \\u003Cdiv class=\\u0022item-list\\u0022\\u003E\\u003Cul\\u003E\\u003C\\/ul\\u003E\\u003C\\/div\\u003E\\n    \\u003C\\/div\\u003E\\n    \\u003C\\/div\\u003E\\n\\u003Cdiv class=\\u0022js-click-to-select subfield-option field-suboption__item\\u0022\\u003E\\n    \\u003Cinput class=\\u0022field-option-radio form-radio form-boolean form-boolean--type-radio\\u0022 data-once=\\u0022field-click-to-select\\u0022 data-drupal-selector=\\u0022field-uientity-referencetaxonomy-term\\u0022 aria-describedby=\\u0022field_ui:entity_reference:taxonomy_term--description\\u0022 type=\\u0022radio\\u0022 id=\\u0022field_ui:entity_reference:taxonomy_term\\u0022 name=\\u0022group_field_options_wrapper\\u0022 value=\\u0022field_ui:entity_reference:taxonomy_term\\u0022\\/\\u003E\\n      \\u003Clabel for=\\u0022field_ui:entity_reference:taxonomy_term\\u0022 class=\\u0022form-item__label option\\u0022\\u003ETaxonomy term\\u003C\\/label\\u003E\\n    \\u003Cdiv id=\\u0022field_ui:entity_reference:taxonomy_term--description\\u0022\\u003E\\n      \\u003Cdiv class=\\u0022item-list\\u0022\\u003E\\u003Cul\\u003E\\u003C\\/ul\\u003E\\u003C\\/div\\u003E\\n    \\u003C\\/div\\u003E\\n    \\u003C\\/div\\u003E\\n\\u003Cdiv class=\\u0022js-click-to-select subfield-option field-suboption__item\\u0022\\u003E\\n    \\u003Cinput class=\\u0022field-option-radio form-radio form-boolean form-boolean--type-radio\\u0022 data-once=\\u0022field-click-to-select\\u0022 data-drupal-selector=\\u0022field-uientity-referenceuser\\u0022 aria-describedby=\\u0022field_ui:entity_reference:user--description\\u0022 type=\\u0022radio\\u0022 id=\\u0022field_ui:entity_reference:user\\u0022 name=\\u0022group_field_options_wrapper\\u0022 value=\\u0022field_ui:entity_reference:user\\u0022\\/\\u003E\\n      \\u003Clabel for=\\u0022field_ui:entity_reference:user\\u0022 class=\\u0022form-item__label option\\u0022\\u003EUser\\u003C\\/label\\u003E\\n    \\u003Cdiv id=\\u0022field_ui:entity_reference:user--description\\u0022\\u003E\\n      \\u003Cdiv class=\\u0022item-list\\u0022\\u003E\\u003Cul\\u003E\\u003C\\/ul\\u003E\\u003C\\/div\\u003E\\n    \\u003C\\/div\\u003E\\n    \\u003C\\/div\\u003E\\n\\u003Cdiv class=\\u0022js-click-to-select subfield-option field-suboption__item\\u0022\\u003E\\n    \\u003Cinput class=\\u0022field-option-radio form-radio form-boolean form-boolean--type-radio\\u0022 data-once=\\u0022field-click-to-select\\u0022 data-drupal-selector=\\u0022entity-reference\\u0022 aria-describedby=\\u0022entity_reference--description\\u0022 type=\\u0022radio\\u0022 id=\\u0022entity_reference\\u0022 name=\\u0022group_field_options_wrapper\\u0022 value=\\u0022entity_reference\\u0022\\/\\u003E\\n      \\u003Clabel for=\\u0022entity_reference\\u0022 class=\\u0022form-item__label option\\u0022\\u003EOther\\u003C\\/label\\u003E\\n    \\u003Cdiv id=\\u0022entity_reference--description\\u0022\\u003E\\n      \\u003Cdiv class=\\u0022item-list\\u0022\\u003E\\u003Cul\\u003E\\u003C\\/ul\\u003E\\u003C\\/div\\u003E\\n    \\u003C\\/div\\u003E\\n    \\u003C\\/div\\u003E\\n\\u003C\\/div\\u003E\\n\\u003C\\/div\\u003E","settings":null}', name: "AjaxError", stack: "@http://rp10.local/core/misc/ajax.js?v=10.2.0:196:32\n@http://rp10.local/core/misc/ajax.js?v=10.2.0:1915:3\n" }
ajax.js:196:32

Click submit, get error that type wasn't chosen, and now selection is enabled below. Pick "User", submit, get to the next screen, attempt to choose "Name" by which to sort, get error:

Uncaught 
Object { message: "\nAn AJAX HTTP error occurred.\nHTTP Result Code: 500\nDebugging information follows.\nPath: /admin/structure/types/manage/project/add-field/node/field_project_manager?destinations%5B0%5D%5Broute_name%5D=entity.node.field_ui_fields&destinations%5B0%5D%5Broute_parameters%5D%5Bentity_type%5D=node&destinations%5B0%5D%5Broute_parameters%5D%5Bfield_name%5D=field_project_manager&destinations%5B0%5D%5Broute_parameters%5D%5Bnode_type%5D=project&destinations%5B1%5D=/admin/structure/types/manage/project/fields/add-field\nStatusText: 500 Service unavailable (with message)\nResponseText: The website encountered an unexpected error. Try again later", name: "AjaxError", stack: "@http://rp10.local/core/misc/ajax.js?v=10.2.0:196:32\n@http://rp10.local/core/misc/ajax.js?v=10.2.0:1915:3\n" }
ajax.js:196:32

Flushing all caches does not help.

Proposed resolution

Remaining tasks

User interface changes

API changes

Data model changes

Release notes snippet

๐Ÿ› Bug report
Status

Active

Version

11.0 ๐Ÿ”ฅ

Component
Ajaxย  โ†’

Last updated about 1 hour ago

Created by

๐Ÿ‡จ๐Ÿ‡ฆCanada sdsheridan Toronto

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • Issue created by @sdsheridan
  • ๐Ÿ‡จ๐Ÿ‡ฆCanada sdsheridan Toronto
  • The steps to reproduce seem like ordinary actions so there must be more steps to reproduce the error condition.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada sdsheridan Toronto

    I wish there were, but no, that's about it. The only other thing I've not indicated is the contrib modules I've got, which are:

    1. address
    2. address_display
    3. admin_toolbar
    4. better_exposed_filters
    5. ckeditor5_findandreplace
    6. ckeditor5_font
    7. color
    8. computed_field
    9. conditional_fields
    10. config_filter
    11. config_split
    12. ctools
    13. devel
    14. devel_php
    15. encrypt
    16. entity_clone
    17. entity_reference_revisions
    18. environment_indicator
    19. feeds
    20. field_group
    21. field_permissions
    22. filefield_paths
    23. genpass
    24. jquery_ui
    25. jquery_ui_datepicker
    26. jquery_ui_slider
    27. jquery_ui_touch_punch
    28. key
    29. libraries
    30. linkit
    31. mail_login
    32. menu_block
    33. name
    34. paragraphs
    35. paragraphs_table
    36. patchinfo
    37. pathauto
    38. realname
    39. real_aes
    40. role_delegation
    41. scroll_top_button
    42. smart_trim
    43. structure_sync
    44. subpathauto
    45. symfony_mailer
    46. taxonomy_manager
    47. telephone_validation
    48. tfa
    49. token
  • ๐Ÿ‡ซ๐Ÿ‡ฎFinland lauriii Finland

    Is there more information about what happened in the PHP error logs?

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada sdsheridan Toronto

    Nothing appears in the PHP error log, or in the watchdog log when these errors occur now. The only thing that appeared in the watchdog was around trying to add a user reference field "Project manager" to a "Project" content type, as follows:

    Type 	php
    Date 	Tuesday, December 19, 2023 - 19:48
    User 	admin
    Location 	http://rp10.local/admin/structure/types/manage/project/add-field/node/field_project_manager?_wrapper_format=drupal_ajax&destinations%5B0%5D%5Broute_name%5D=entity.node.field_ui_fields&destinations%5B0%5D%5Broute_parameters%5D%5Bentity_type%5D=node&destinations%5B0%5D%5Broute_parameters%5D%5Bfield_name%5D=field_project_manager&destinations%5B0%5D%5Broute_parameters%5D%5Bnode_type%5D=project&destinations%5B1%5D=%2Fadmin%2Fstructure%2Ftypes%2Fmanage%2Fproject%2Ffields%2Fadd-field
    Referrer 	http://rp10.local/admin/structure/types/manage/project/add-field/node/field_project_manager?destinations%5B0%5D%5Broute_name%5D=entity.node.field_ui_fields&destinations%5B0%5D%5Broute_parameters%5D%5Bentity_type%5D=node&destinations%5B0%5D%5Broute_parameters%5D%5Bfield_name%5D=field_project_manager&destinations%5B0%5D%5Broute_parameters%5D%5Bnode_type%5D=project&destinations%5B1%5D=/admin/structure/types/manage/project/fields/add-field
    Message 	InvalidArgumentException: Field field_project_manager is unknown. in Drupal\Core\Entity\ContentEntityBase->getTranslatedField() (line 616 of D:\var\www\rp10.local\web\core\lib\Drupal\Core\Entity\ContentEntityBase.php).
    Severity 	Error
    Hostname 	127.0.0.1
    Operations 	
    Backtrace 	
    
    #0 D:\var\www\rp10.local\web\core\lib\Drupal\Core\Entity\ContentEntityBase.php(597): Drupal\Core\Entity\ContentEntityBase->getTranslatedField('field_project_m...', 'x-default')
    #1 D:\var\www\rp10.local\web\core\modules\field_ui\src\Form\FieldStorageConfigEditForm.php(116): Drupal\Core\Entity\ContentEntityBase->get('field_project_m...')
    #2 D:\var\www\rp10.local\web\core\lib\Drupal\Core\Entity\EntityForm.php(107): Drupal\field_ui\Form\FieldStorageConfigEditForm->form(Array, Object(Drupal\Core\Form\SubformState))
    #3 D:\var\www\rp10.local\web\core\modules\field_ui\src\Form\FieldStorageConfigEditForm.php(85): Drupal\Core\Entity\EntityForm->buildForm(Array, Object(Drupal\Core\Form\SubformState))
    #4 D:\var\www\rp10.local\web\core\modules\field_ui\src\Form\FieldConfigEditForm.php(199): Drupal\field_ui\Form\FieldStorageConfigEditForm->buildForm(Array, Object(Drupal\Core\Form\SubformState), Object(Drupal\field\Entity\FieldConfig))
    #5 D:\var\www\rp10.local\web\core\lib\Drupal\Core\Entity\EntityForm.php(107): Drupal\field_ui\Form\FieldConfigEditForm->form(Array, Object(Drupal\Core\Form\FormState))
    #6 [internal function]: Drupal\Core\Entity\EntityForm->buildForm(Array, Object(Drupal\Core\Form\FormState))
    #7 D:\var\www\rp10.local\web\core\lib\Drupal\Core\Form\FormBuilder.php(536): call_user_func_array(Array, Array)
    #8 D:\var\www\rp10.local\web\core\lib\Drupal\Core\Form\FormBuilder.php(375): Drupal\Core\Form\FormBuilder->retrieveForm('field_config_ed...', Object(Drupal\Core\Form\FormState))
    #9 D:\var\www\rp10.local\web\core\lib\Drupal\Core\Form\FormBuilder.php(633): Drupal\Core\Form\FormBuilder->rebuildForm('field_config_ed...', Object(Drupal\Core\Form\FormState), Array)
    #10 D:\var\www\rp10.local\web\core\lib\Drupal\Core\Form\FormBuilder.php(325): Drupal\Core\Form\FormBuilder->processForm('field_config_ed...', Array, Object(Drupal\Core\Form\FormState))
    #11 D:\var\www\rp10.local\web\core\lib\Drupal\Core\Entity\EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm(Object(Drupal\field_ui\Form\FieldConfigEditForm), Object(Drupal\Core\Form\FormState))
    #12 D:\var\www\rp10.local\web\core\modules\field_ui\src\Controller\FieldConfigAddController.php(62): Drupal\Core\Entity\EntityFormBuilder->getForm(Object(Drupal\field\Entity\FieldConfig), 'default', Array)
    #13 [internal function]: Drupal\field_ui\Controller\FieldConfigAddController->fieldConfigAddConfigureForm('node', 'field_project_m...')
    #14 D:\var\www\rp10.local\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array(Array, Array)
    #15 D:\var\www\rp10.local\web\core\lib\Drupal\Core\Render\Renderer.php(627): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #16 D:\var\www\rp10.local\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext(Object(Drupal\Core\Render\RenderContext), Object(Closure))
    #17 D:\var\www\rp10.local\web\core\lib\Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext(Array, Array)
    #18 D:\var\www\rp10.local\vendor\symfony\http-kernel\HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #19 D:\var\www\rp10.local\vendor\symfony\http-kernel\HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw(Object(Symfony\Component\HttpFoundation\Request), 1)
    #20 D:\var\www\rp10.local\web\core\lib\Drupal\Core\StackMiddleware\Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #21 D:\var\www\rp10.local\web\core\lib\Drupal\Core\StackMiddleware\KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #22 D:\var\www\rp10.local\web\core\modules\page_cache\src\StackMiddleware\PageCache.php(106): Drupal\Core\StackMiddleware\KernelPreHandle->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #23 D:\var\www\rp10.local\web\core\modules\page_cache\src\StackMiddleware\PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #24 D:\var\www\rp10.local\web\core\lib\Drupal\Core\StackMiddleware\ReverseProxyMiddleware.php(48): Drupal\page_cache\StackMiddleware\PageCache->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #25 D:\var\www\rp10.local\web\core\lib\Drupal\Core\StackMiddleware\NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #26 D:\var\www\rp10.local\web\core\lib\Drupal\Core\StackMiddleware\AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #27 D:\var\www\rp10.local\web\core\lib\Drupal\Core\StackMiddleware\StackedHttpKernel.php(51): Drupal\Core\StackMiddleware\AjaxPageState->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #28 D:\var\www\rp10.local\web\core\lib\Drupal\Core\DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle(Object(Symfony\Component\HttpFoundation\Request), 1, true)
    #29 D:\var\www\rp10.local\web\index.php(19): Drupal\Core\DrupalKernel->handle(Object(Symfony\Component\HttpFoundation\Request))
    #30 {main}
    
  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sunfire-design

    I have the same problem after 10.2.0.
    After submitting every ajax form sends an error to the developver console.
    I deactivated almost every non core module but the error still appears.

  • same here after update to 10.2.0

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada sdsheridan Toronto

    If it helps, I observed this behaviour on both an updated site from 10.1.7, and on a fresh install of 10.2.0.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States ikphilip Charlotte, NC, USA

    I've looked at your issue and I think I encountered a similar error using Layout Builder. I identified what's happening in my instance so I will comment here in case this helps. I am unsure where this error originates.

    1. Using Layout Builder in 10.2.0. Try to add block to existing layout. Console error. Uncaught AjaxError. No Watchdog errors. This is because the Return status is 200 so the response is generated on Drupal without errors. So I investigate web/core/misc/ajax.js library to see what's going on.
    2. Trace things to object ajax.options.complete function (line 611) check to see what type of error it is. I find it's a 'parsererror'. So jQuery is unable to parse the JSON response.
    3. Inspect the Response from Drupal/server. Notice that the JSON is malformed. In fact you can see this in your ResponseText object in the code you pasted in the issue. The JSON array opens with a '[' and there is no closing ']'.
    4. At this point I try to trace the problem to Drupal. Check out Symfony\Component\HttpFoundation\JsonResponse::setData() and attempt to see why it's being malformed. However I find that the JSON is leaving this function differently than it arrives to the browser.
    5. I don't try to trace this anymore. Backtrack to ajax.js and process responses as 'text' (instead of 'json') and check for this particular error.

    That's all the time I've spent on this problem. If you believe my problem is similar to yours perhaps this patch workaround for 10.2.0 will alleviate the current issue. It doesn't fix the root of the problem which is why ResponseText JSON reaches the client without the closing bracket ']'.

    I will note that I didn't encounter this problem on a new Drupal 10.2.0 site using standard profile and layout builder. Layout Builder was the only Ajax affected on my current site where traced the problem. On that site I could not replicate with other Ajax behaviors like in Views.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States ikphilip Charlotte, NC, USA

    Further investigation into this issue.

    As I mentioned in comment #10 ๐Ÿ› Uncaught ajax.js error / exception Active I didn't encounter this problem in 10.1.7. I was able to downgrade my site and LayoutBuilder Ajax worked properly again. The JSON content response was formed correctly in 10.1.7.

    I began experimenting with sending Content-Length header, which I noticed was missing from the Ajax responses. I found that the Content-Length didn't appear on my malformed application/json responses despite trying to add it in 10.2.0 site. Then I added the content header to my 10.1.7 site before Response::send() and I discovered the response was malformed! So I determined that setting Content-Length for certain applicaton/json responses appears to cause the issue where the JSON content arrives malformed to the browser/client.

    I've attached another patch for testing. It doesn't address the root cause and is a naive attempt at removing Content-Length from the AjaxResponse class, no others. You'll either want to adjust or remove the condition if you need to target other types of Responses. However I hope this is starting to illuminate the underlying issue.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    @ikphilip that's good investigation, and means this issue is likely a duplicate of ๐Ÿ› Only set content-length header in specific situations Fixed - could you try the MR from there?

  • ๐Ÿ‡ญ๐Ÿ‡บHungary czigor

    I have a commerce add to cart form that fails like this. The MR in ๐Ÿ› Only set content-length header in specific situations Fixed does not solve the issue, I guess because the AJAX response has a 200 status for which Content-Length is still added after applying the MR.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States ikphilip Charlotte, NC, USA

    I just tested the MR in ๐Ÿ› Only set content-length header in specific situations Fixed and it did not work for me. My site's failing AJAX responses are 200 and therefore deserving of a Content-Length header.

    What I noticed is that my Content-Length byte count appears to be off by 1. If I modify this line in FinishResponseSubscriber.php the responses begin to work. Something like

    $response->headers->set('Content-Length', mb_strlen($content) + 1, TRUE);

    Because I'm unable to replicate this problem on a fresh install of 10.2.0 I'm beginning to wonder if there is something the matter with specific data from the site's content.

    So for me adding +1 to the byte length helps. This is likely why in the browser/curl/client the response appears truncated. But why is strlen() failing?

  • ๐Ÿ‡ญ๐Ÿ‡บHungary czigor

    In my case it turned out to be extra white space in front of a <?php tag. I used the regexp \s+<\?php to find such occurences in my codebase.

    @ikphilip Looks like you have a similar issue.

  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark William H. Olesen

    I'm experiencing a similar issue after upgrading to D10.2.0 where I get the Ajax-error in the browser-console.

    No problems locally though where this is the setup:

    • MAMP Pro,
    • PHP 8.2.0 (also tried 8.1.13 - no problems)
    • Apache/2.4.54 (Unix)
    • MacOs 14.1.1

    But on prod (on a subdomain) I get the error when trying add an image via Media library and when trying to Add media in a node. The set up is like this:

    • Apache/2.4.29 (Ubuntu)
    • PHP 8.1.26
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States ikphilip Charlotte, NC, USA

    Checking for extra spaces in the the file is a good idea, thank you @czigor. I've checked for the existence of spaces before my opening PHP tags. No luck finding a culprit file...

    I think the simplest work-around until the source of the issue is identified is to disable Content-Length header via patch on a site-by-site basis with something akin to my example patch in #11. Should I find anything related I'll report it here.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch
  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark William H. Olesen

    I experienced another symptom of the problem when synchronizing configuration - the patch in #10 IS put on and fixes my initial problems, but not this one.

    When I click import the sync progress bar appears and after a little while I get the "Oops, something went wrong etc." and the following in a message above (but the synchronization has been completed correctly though):

    An AJAX HTTP error occurred.
    HTTP Result Code: 200
    Debugging information follows.
    Path: /batch?id=9&op=do_nojs&op=do
    StatusText: parsererror
    ResponseText: {"status":true,"percentage":"75","message":"Completed step 3 of 4.","label":""

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    @William H. Olesen could you try applying the diff from ๐Ÿ› Regression from #3295790 content-length header set earlier than expected Fixed ?

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States ikphilip Charlotte, NC, USA

    @William H. Olesen as the author of the patch in comment #10 I don't recommend you rely on it. Notice that the patch only checks for unclosed JSON arrays "[]" not objects "{}" and as a result your ResponseText in #19 won't be fixed.

    You could probably modify Patch #10 to check for unclosed JSON objects, if you wish. Since the problem is server-side with the Content-Length I don't believe a patch like #10 is appropriate. Consider #11 or a similar patch to unset Content-Length from the AjaxResponse for the time being since it wasn't delivered prior to version 10.2.0.

    As for me, no luck with 10.2.x patch from https://www.drupal.org/project/drupal/issues/3410022 ๐Ÿ› Regression from #3295790 content-length header set earlier than expected Fixed . My goal is to review the impact of various contrib modules to see if there is something akin to the solution in #15 but I've nothing to report yet. Since I can't replicate this in a fresh install of Drupal I'm wondering if it's something from contrib.

  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark William H. Olesen

    @catch I'm a simple site builder and on pretty deep water here, so I'm not quite sure what you mean - I'll be happy to try if you can explain.

    @ikphilip Thanks for the heads up - it allowed for editors to continue throwing in content before launch of the site, so as a temporary solution it did the job - I'll try to avoid putting it on live prod ;)

  • ๐Ÿ‡ฉ๐Ÿ‡ฐDenmark William H. Olesen

    I just installed Drupal 10.1.2 where "#3410022: Regression from #3295790 content-length header set earlier than expected" were said to be fixed, but the issues I have remain.

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine chesn0k Ukraine, Odessa

    I'm having this issue in a new installation of Drupal.

    1 drush si
    2 Try opening Announcements

    I tracked the response body while calculating the content length, the response body is valid.
    If assume that the length calculated is incorrect and add +1 this will solve the issue.

    Drupal\Core\StackMiddleware\ContentLength:
    $response->headers->set('Content-Length', strlen($content) + 1, TRUE);

    I have no idea where to look for the bug next )

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia larowlan ๐Ÿ‡ฆ๐Ÿ‡บ๐Ÿ.au GMT+10

    I wonder if you have a space before an opening PHP tag somewhere

  • ๐Ÿ‡บ๐Ÿ‡ฆUkraine chesn0k Ukraine, Odessa

    I checked the only file I created settings.php without a space.
    I also deleted the installation and reinstalled it and now I canโ€™t get this bug again.

    In any case, I now think this is not connected with drupal, but with the IDE (PHPStorm) or the environment

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sunfire-design

    Thanks for the advice.
    In my case it was a whitespace in the bat module.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    @sunfire-design is there an issue against the bat module for the extra whitespace?

    I wonder whether phpcs picks this up already and those modules don't have gitlab pipelines enabled, or if we're missing a rule somewhere.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States ikphilip Charlotte, NC, USA

    I've finally resolved my site's issue. I found a new line before the open PHP tag in a module...my own custom module! Thanks all.

  • That looks good.

    A slight adjustment to \n+<\?php will match in cases where there is more than one new line.

  • ๐Ÿ‡ฉ๐Ÿ‡ชGermany sunfire-design

    @catch i created an issue report. The whitespace is only in the 2.1 branch.

  • ๐Ÿ‡ช๐Ÿ‡ธSpain rcodina Barcelona

    On Drupal 10.2.0, patch on #10 works for me, patch #11 doesn't apply and patch #14 breaks my site.

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada sdsheridan Toronto

    I checked my entire project directory, and found that indeed one of my own custom modules had a space before the opening '<?php' tag. Use the following to find them:

    $ pcregrep -Mlr --buffer-size=1048576 "^\s+<\?php" .
    

    There were a number of items that showed up under ./vendor, and then my module.

    I now seem to be no longer getting "something went wrong" errors, and fields are adding correctly now.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia drupalite1411

    If I take the code from #11 and manually apply it ,it fixes ajax issue but quick edit issue is still there.
    I have reported this issue here. I am facing ajax as well as contextual links not appearing issue.
    https://www.drupal.org/project/drupal/issues/3414753 ๐Ÿ› Drupal ajax error after D10 update from version 10.0.11 to 10.2.1 Needs review

    Also how to apply this patch using composer.json?

     "patches": {
              "drupal/http-foundation": {
                "Ajax issue": "https://www.drupal.org/files/issues/2023-12-23/symfony_http-foundation_unset-content-length.patch"
              }
            },
  • ๐Ÿ‡บ๐Ÿ‡ธUnited States ikphilip Charlotte, NC, USA

    I've created 2 more patches for Drupal for users who are having issues with Content-Length headers in Drupal responses in 10.2. These patches disable setting the header so that the responses resemble those from prior versions (<10.2). I discourage the usage of my patches #10, #11, #14 as they existed to fix a specific response and to illustrate the problem I was facing.

    In 10.2.0 Content-Length response header was introduced and set in FinishResponseSubscriber.php. In 10.2.1 the logic was moved to a StackMiddleware class ContentLength which is enabled in core.services.yml. You must use the appropriate patch for your current version.

    I do recommend checking to see if there is extra spacing anywhere before the opening PHP tag <?php as that appears to be the problem for many of us. However I understand that combing a codebase can take time and it took me some time to identify the problem file so these patches can help until the problem is identified.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States couloir007

    I used the 10.2.1 patch on 10.2.2, and it worked. It seems impractical to worry about spaces before an opening php tag, given how many of the vendor files contain these. Also, this was only an issue on my local Lando, not on my production servers.

  • What helped on my end: Remove all php closing tags from your source code (?>). This is especially important when migrating older php code to Drupal 10.2.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States jjmackow

    I had been experiencing this Ajax error also, while creating a view. To be clear, the error was:
    "Oops, something went wrong. Check your browser's developer console for more details."
    what resolved the issue for me was to shorten the machine name of the view display. It had been 40+ characters long and I reduced it to something less than 16 characters.

  • We used the 10.2.1 patch on 10.2.3 with no issues. Very weird issue as it only happened on one of our production servers but could not be reproduced anywhere where, including local. Thank you for this patch, it got us back up and running after 4 days of searching for an answer.

  • ๐Ÿ‡ฎ๐Ÿ‡ณIndia drupalite1411

    I have used #35 10.2.1 patch and it worked.

  • ๐Ÿ‡น๐Ÿ‡ญThailand AlfTheCat

    I applied the 10.2.0 patch on a 10.2.3 install and no luck.

    I have this problem on all my sites, everywhere now. Mostly layout builder (can't add sections, can't add certain blocks) but also elsewhere (can't set default images for fields).

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada kylebehse

    SOLVED: Drupal, "Oops, something went wrong. Check your browser's developer console for more details."
    Yep, same here (line-break on line 1 of custom module).
    To fix:
    Go to a plain text editor, create new file, hit enter (to create a line-break), select all, copy.
    Go to code editor, search entire site for:
    Paste the line-break in, then type "<?"

    It should find any line-breaks in line 1 of code. Note: I use the copy and paste technique because hitting enter in the search bar of the code editor means that you want it to search, not insert a new line.

    This was hard to see, as VSCode had a helper icon blocking line #1.

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance erwangel

    The Ajax issue is still present on 10.2.4. In a custom module I have a very simple form, I simplified the ajax response to jus say "Hello", I switched to the default Olivero theme to be sure there is no interference with any other jquery or ajax call. This form was working with no problem on 10.1.2.

    What I noticed in the console display of he error is that whatever the context of my form is used (and so producing variable ajax responses), it always has a "settings"; nul' in the response text. This quote after nul sounds suspect to me.

    message: '\nAn AJAX HTTP error occurred.\nHTTP Result Code: 200\nDebugging information follows.\nPath: /path_to_the_calling_page?ajax_form=1\nStatusText: parsererror\n
    
    ResponseText: 
    
    [
    
    {"command":"update_build_id","old":"form-rjF70Nh6-v5uOijTmG0ZX6MHU8dDqTYYjLsJzf79Stk",
    "new":"form-LHnajKIYq8szIGH0kkk-4vqtqzU_FsZmY2tLXUHqkqc"},
    
    {
    "command":"insert",
    "method":"replaceWith",
    "selector":"#my_ajax_form_element",
    "data":"Hello",
    "settings":nul'
    โ€‹
    name: "AjaxError"
    โ€‹
    stack: "@https://my_site.com/core/misc/ajax.js?v=10.2.4:196:32\n@https://my_site.com/core/misc/ajax.js?v=10.2.4:1916:3\n"
    โ€‹
    <prototype>: Error: 
    ajax.js:196:32 etc.
    

    Extra line-breaks are mine to make it evident that there is a malformed json array, probably due tho the nul'.

    I tried patch 10.2.1 from #35, it worked on the first call of the form (a click on submit button), but it didn't work on the next calls although there was no error displayed on the console.

  • ๐Ÿ‡ธ๐Ÿ‡ฎSlovenia KlemenDEV

    I would be happy to help further if I understood the details of this, but this issue is probably preventing many websites from updating to 10.2

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia marc.groth

    Similar to #42, I am also unable to add a default image. In fact I can't save any image field (new or re-used). The following error is logged:

    InvalidArgumentException: Placeholders must have a trailing [] if they are to be expanded with an array of values. in Drupal\Core\Database\Connection->expandArguments() (line 896 of /var/www/html/web/core/lib/Drupal/Core/Database/Connection.php).
    
    #0 /var/www/html/web/core/lib/Drupal/Core/Database/Connection.php(822): Drupal\Core\Database\Connection->expandArguments()
    #1 /var/www/html/web/core/lib/Drupal/Core/Database/Query/Select.php(525): Drupal\Core\Database\Connection->query()
    #2 /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(271): Drupal\Core\Database\Query\Select->execute()
    #3 /var/www/html/web/core/lib/Drupal/Core/Entity/Query/Sql/Query.php(84): Drupal\Core\Entity\Query\Sql\Query->result()
    #4 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(607): Drupal\Core\Entity\Query\Sql\Query->execute()
    #5 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityRepository.php(63): Drupal\Core\Entity\EntityStorageBase->loadByProperties()
    #6 /var/www/html/web/core/modules/image/image.module(355): Drupal\Core\Entity\EntityRepository->loadEntityByUuid()
    #7 [internal function]: image_entity_presave()
    #8 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(409): call_user_func_array()
    #9 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(388): Drupal\Core\Extension\ModuleHandler->Drupal\Core\Extension\{closure}()
    #10 /var/www/html/web/core/lib/Drupal/Core/Extension/ModuleHandler.php(408): Drupal\Core\Extension\ModuleHandler->invokeAllWith()
    #11 /var/www/html/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(343): Drupal\Core\Extension\ModuleHandler->invokeAll()
    #12 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(529): Drupal\Core\Config\Entity\ConfigEntityStorage->invokeHook()
    #13 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityStorageBase.php(483): Drupal\Core\Entity\EntityStorageBase->doPreSave()
    #14 /var/www/html/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityStorage.php(257): Drupal\Core\Entity\EntityStorageBase->save()
    #15 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityBase.php(352): Drupal\Core\Config\Entity\ConfigEntityStorage->save()
    #16 /var/www/html/web/core/lib/Drupal/Core/Config/Entity/ConfigEntityBase.php(609): Drupal\Core\Entity\EntityBase->save()
    #17 /var/www/html/web/modules/contrib/field_permissions/field_permissions.module(137): Drupal\Core\Config\Entity\ConfigEntityBase->save()
    #18 [internal function]: field_permissions_field_config_edit_form_builder()
    #19 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityForm.php(307): call_user_func_array()
    #20 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityForm.php(171): Drupal\Core\Entity\EntityForm->buildEntity()
    #21 /var/www/html/web/core/modules/field_ui/src/Form/FieldConfigEditForm.php(278): Drupal\Core\Entity\EntityForm->afterBuild()
    #22 [internal function]: Drupal\field_ui\Form\FieldConfigEditForm->afterBuild()
    #23 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(1084): call_user_func_array()
    #24 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(579): Drupal\Core\Form\FormBuilder->doBuildForm()
    #25 /var/www/html/web/core/lib/Drupal/Core/Form/FormBuilder.php(325): Drupal\Core\Form\FormBuilder->processForm()
    #26 /var/www/html/web/core/lib/Drupal/Core/Entity/EntityFormBuilder.php(48): Drupal\Core\Form\FormBuilder->buildForm()
    #27 /var/www/html/web/core/modules/field_ui/src/Controller/FieldConfigAddController.php(62): Drupal\Core\Entity\EntityFormBuilder->getForm()
    #28 [internal function]: Drupal\field_ui\Controller\FieldConfigAddController->fieldConfigAddConfigureForm()
    #29 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(123): call_user_func_array()
    #30 /var/www/html/web/core/lib/Drupal/Core/Render/Renderer.php(627): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #31 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(121): Drupal\Core\Render\Renderer->executeInRenderContext()
    #32 /var/www/html/web/core/lib/Drupal/Core/EventSubscriber/EarlyRenderingControllerWrapperSubscriber.php(97): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->wrapControllerExecutionInRenderContext()
    #33 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(181): Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber->Drupal\Core\EventSubscriber\{closure}()
    #34 /var/www/html/vendor/symfony/http-kernel/HttpKernel.php(76): Symfony\Component\HttpKernel\HttpKernel->handleRaw()
    #35 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/Session.php(58): Symfony\Component\HttpKernel\HttpKernel->handle()
    #36 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/KernelPreHandle.php(48): Drupal\Core\StackMiddleware\Session->handle()
    #37 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ContentLength.php(28): Drupal\Core\StackMiddleware\KernelPreHandle->handle()
    #38 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(106): Drupal\Core\StackMiddleware\ContentLength->handle()
    #39 /var/www/html/web/core/modules/page_cache/src/StackMiddleware/PageCache.php(85): Drupal\page_cache\StackMiddleware\PageCache->pass()
    #40 /var/www/html/web/modules/contrib/shield/src/ShieldMiddleware.php(270): Drupal\page_cache\StackMiddleware\PageCache->handle()
    #41 /var/www/html/web/modules/contrib/shield/src/ShieldMiddleware.php(155): Drupal\shield\ShieldMiddleware->bypass()
    #42 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/ReverseProxyMiddleware.php(48): Drupal\shield\ShieldMiddleware->handle()
    #43 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/NegotiationMiddleware.php(51): Drupal\Core\StackMiddleware\ReverseProxyMiddleware->handle()
    #44 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/AjaxPageState.php(36): Drupal\Core\StackMiddleware\NegotiationMiddleware->handle()
    #45 /var/www/html/web/modules/contrib/remove_http_headers/src/StackMiddleware/RemoveHttpHeadersMiddleware.php(49): Drupal\Core\StackMiddleware\AjaxPageState->handle()
    #46 /var/www/html/web/core/lib/Drupal/Core/StackMiddleware/StackedHttpKernel.php(51): Drupal\remove_http_headers\StackMiddleware\RemoveHttpHeadersMiddleware->handle()
    #47 /var/www/html/web/core/lib/Drupal/Core/DrupalKernel.php(704): Drupal\Core\StackMiddleware\StackedHttpKernel->handle()
    #48 /var/www/html/web/index.php(19): Drupal\Core\DrupalKernel->handle()
    #49 {main}
    

    I'm not able to add a dynamic 'Content' reference field:

    Drupal\Core\Entity\EntityStorageException: 'field_storage_config' entity with ID 'node.field_content_reference' already exists. in Drupal\Core\Entity\EntityStorageBase->doPreSave() (line 519 of core/lib/Drupal/Core/Entity/EntityStorageBase.php).

    And also not able to add a regular 'Content' reference field:

    InvalidArgumentException: Field field_new_content_reference is unknown. in Drupal\Core\Entity\ContentEntityBase-&gt;getTranslatedField() (line 616 of core/lib/Drupal/Core/Entity/ContentEntityBase.php). Drupal\Core\Entity\ContentEntityBase-&gt;get() (Line: 116)

    All of these issues are only in 10.2.x (including the 10.2.4). 10.1.8 and earlier work fine.

    I did notice that the UI for this functionality has changed in the 10.2 branch; so assume this is related.

  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom catch

    #42 and #46 look unrelated to the original issues reported here (which are about whitespace in PHP files) - it looks more likely to be a contrib module altering a form that needs an update to 10.2 or similar. First check that your modules are all up-to-date.

    @marc.groth are you using DER? https://www.drupal.org/project/dynamic_entity_reference โ†’

  • ๐Ÿ‡จ๐Ÿ‡ฆCanada orizonmedia

    hi all,

    I'm on Drupal 10.2.4 with PHP8.2.17 I tried #35 10.2 and 10.1 (tried both) and got error cannot apply patch.

    Am I missing something in my composer? Thanks in advance!

    "drupal/core": {
    "#35 https://www.drupal.org/project/drupal/issues/3409885 ๐Ÿ› Uncaught ajax.js error / exception Active ": " https://www.drupal.org/files/issues/2024-01-16/disable-ContentLength-htt... โ†’ "
    }

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia marc.groth

    Thanks @catch. That is a really good point! We have a number of outdated contrib modules. In the past we have been able to update Drupal core first; but it makes sense to get the contrib modules updated first.

    And to answer your question, yes we are using the DER module.

    Thanks for your suggestions and sorry for the temporary noise in this ticket :)

    Everyone please disregard #46

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States tenten71

    #15 worked for me. Thank you. Spent all day reading and researching this.

    I had just updated our TEST server to 10.2.5 and was having AJAX errors caused while trying to run manual updates, add media, add images, remove images, edit fields in Views... Didn't have these issues on our DEV server which was running the same version. However we did copy our LIVE server over to our TEST server, so at first I thought it was something else.

    Thank you for the regexp so I didn't have to look that up myself.

    The culprit was in the web/sites/default/settings.php file. A lonely blank line above the opening <?php tag. The version on our DEV and LIVE servers did not have this line so I'm still trying to figure out who/how this appeared.

  • Having this issue as well after upgrading to 10.2.2 from 10.1.6. Checked for spacing on <?php, no dice.

    Patch #35 unfortunately did not work.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States santhoshabraham

    I am having same issue after updating Drupal. When I submit webform I get following error.
    Oops, something went wrong. Check your browser's developer console for more details.

  • last update 8 months ago
    Patch Failed to Apply
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom astoker88

    If anyone else encounters this issue, i had updated the Cloudflare WAF rules to the latest version.
    '/cdn-cgi/challenge-platform' was in the response for all ajax requests. Disabling the items in screenshot fixed the issue.

  • ๐Ÿ‡ต๐Ÿ‡นPortugal fcertal

    Thanks guys!

    A break line before <?php in a custom module was causing an ajax parse error, breaking the batch update process.

  • ๐Ÿ‡ฆ๐Ÿ‡บAustralia gigimaor Narangba/Brisbane

    I am experiencing the same issue as ticket #54.
    I followed up on #15 and found the issue pretty quickly.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States joshua.boltz

    I am running into this same issue. I believe this issue cropped up with a Drupal 10.2 upgrade, because I'm pretty sure it used to work on 10.1.

    Basically, I can reproduce the issue by adding an entity reference field to any content type, and when I change options on the field (that do some Ajax operations) like changing the type of content to reference or changing limited/unlimited options, I get the Ajax error.

    "
    An AJAX HTTP error occurred.
    HTTP Result Code: 500
    Debugging information follows.
    Path: /admin/structure/types/manage/author/add-field/node/field_refer?destinations%5B0%5D%5Broute_name%5D=entity.node.field_ui_fields&destinations%5B0%5D%5Broute_parameters%5D%5Bentity_type%5D=node&destinations%5B0%5D%5Broute_parameters%5D%5Bfield_name%5D=field_refer&destinations%5B0%5D%5Broute_parameters%5D%5Bnode_type%5D=author&destinations%5B1%5D=/admin/structure/types/manage/author/fields/add-field
    StatusText: error
    ResponseText: The website encountered an unexpected error. Try again later.InvalidArgumentException: Field field_refer is unknown. in Drupal\Core\Entity\ContentEntityBase-&gt;getTranslatedField() (line 616 of core/lib/Drupal/Core/Entity/ContentEntityBase.php). Drupal\Core\Entity\ContentEntityBase-&gt;get(&#039;field_refer&#039;) (Line: 116)
    Drupal\field_ui\Form\FieldStorageConfigEditForm-&gt;form(Array, Object) (Line: 107)
    Drupal\Core\Entity\EntityForm-&gt;buildForm(Array, Object) (Line: 85)
    Drupal\field_ui\Form\FieldStorageConfigEditForm-&gt;buildForm(Array, Object, Object) (Line: 199)
    Drupal\field_ui\Form\FieldConfigEditForm-&gt;form(Array, Object) (Line: 107)
    Drupal\Core\Entity\EntityForm-&gt;buildForm(Array, Object)
    call_user_func_array(Array, Array) (Line: 536)
    Drupal\Core\Form\FormBuilder-&gt;retrieveForm(&#039;field_config_edit_form&#039;, Object) (Line: 375)
    Drupal\Core\Form\FormBuilder-&gt;rebuildForm(&#039;field_config_edit_form&#039;, Object, Array) (Line: 633)
    Drupal\Core\Form\FormBuilder-&gt;processForm(&#039;field_config_edit_form&#039;, Array, Object) (Line: 325)
    Drupal\Core\Form\FormBuilder-&gt;buildForm(Object, Object) (Line: 48)
    Drupal\Core\Entity\EntityFormBuilder-&gt;getForm(Object, &#039;default&#039;, Array) (Line: 63)
    Drupal\field_ui\Controller\FieldConfigAddController-&gt;fieldConfigAddConfigureForm(&#039;node&#039;, &#039;field_refer&#039;)
    call_user_func_array(Array, Array) (Line: 123)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 627)
    Drupal\Core\Render\Renderer-&gt;executeInRenderContext(Object, Object) (Line: 124)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;wrapControllerExecutionInRenderContext(Array, Array) (Line: 97)
    Drupal\Core\EventSubscriber\EarlyRenderingControllerWrapperSubscriber-&gt;Drupal\Core\EventSubscriber\{closure}() (Line: 181)
    Symfony\Component\HttpKernel\HttpKernel-&gt;handleRaw(Object, 1) (Line: 76)
    Symfony\Component\HttpKernel\HttpKernel-&gt;handle(Object, 1, 1) (Line: 58)
    Drupal\Core\StackMiddleware\Session-&gt;handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\KernelPreHandle-&gt;handle(Object, 1, 1) (Line: 28)
    Drupal\Core\StackMiddleware\ContentLength-&gt;handle(Object, 1, 1) (Line: 106)
    Drupal\page_cache\StackMiddleware\PageCache-&gt;pass(Object, 1, 1) (Line: 85)
    Drupal\page_cache\StackMiddleware\PageCache-&gt;handle(Object, 1, 1) (Line: 50)
    Drupal\ban\BanMiddleware-&gt;handle(Object, 1, 1) (Line: 48)
    Drupal\Core\StackMiddleware\ReverseProxyMiddleware-&gt;handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\NegotiationMiddleware-&gt;handle(Object, 1, 1) (Line: 36)
    Drupal\Core\StackMiddleware\AjaxPageState-&gt;handle(Object, 1, 1) (Line: 51)
    Drupal\Core\StackMiddleware\StackedHttpKernel-&gt;handle(Object, 1, 1) (Line: 704)
    Drupal\Core\DrupalKernel-&gt;handle(Object) (Line: 19)
    "
    
  • ๐Ÿ‡ฌ๐Ÿ‡งUnited Kingdom jprj

    Also happens when trying to 'add another item' to a Selection list field (in my case 'List (text)') and when trying to change the allowed number of values.

  • ๐Ÿ‡บ๐Ÿ‡ธUnited States bob.hinrichs

    If you come across this, check your theme debug settings and make sure the feature is turned off.

  • ๐Ÿ‡ป๐Ÿ‡ณVietnam linhnm

    Thanks guys!

    #15 save my life.

  • ๐Ÿ‡ต๐Ÿ‡นPortugal cleverson.oliveira

    #10 worked for me!

  • ๐Ÿ‡ซ๐Ÿ‡ทFrance nicolasgraph Strasbourg

    In my case it was also a line break before <?php in a custom module which broke Ajax in many places.

  • Ran into this parse error, would happen on firefox and safari, but didnt occur with chrome

    #10 also worked for me when working locally with DDEV, but it still wouldnt work on the stage site

    In my case I noticed the response headers on the stage were missing the content-encoding: gzip

    Tweaked our nginx.conf with some additional gzip settings and it finally worked

  • ๐Ÿ‡ฎ๐Ÿ‡นItaly ziobudda

    Today I upgraded from v9.5 to v10.3.6 and I also had the broken ajax issue. Solution #10 fixed the issue.

Production build 0.71.5 2024