- Issue created by @Carlitus
- ๐บ๐ธUnited States TolstoyDotCom L.A.
I looked into this a bit. I'm not familiar with this module, but that URL returns invalid JSON without having to do any setup.
After enabling the module, when I access
http://127.0.0.1/drupal1020/web/bat_api/calendar-units?_format=json&types=7&ids=&event_type=availability_hourly&_=1703844559776
I get this:
{"message":"No route found for \u0022GET http:\/\/127.0.0.1\/drupal1020\/web\/bat_api\/calendar-units\u0022
However, in Symfony\Component\HttpKernel\HttpKernel::handle, when I change the code so it has
$response = $this->handleThrowable($e, $request, $type);
and then print out'' . $response
, I get correct JSON. That is, converting$response
to a string at that point is not missing the final"}
.As a wild guess, there was a workaround added that cuts off the last two characters of the return value, but whatever the workaround was for no longer applies.
- Status changed to Needs work
12 months ago 3:42pm 2 January 2024 - Status changed to Postponed: needs info
12 months ago 3:49pm 2 January 2024 - ๐ฎ๐นItaly afagioli Rome
About #3, can you please confing the url
" http://127.0.0.1/drupal1020/web/bat_api/calendar-units?_format=json&type..."It should be something like: WEBSERVERNAME + "/bat_api/calendar....."
- ๐ฎ๐นItaly afagioli Rome
On fresh new install, Drupal Version 10.2.0,
/bat_api/calendar-units?_format=json&types=1&ids=&event_type=availability_hourly&_=1703844559776
produces a correct json output:
[{"id":"1","title":"Apts Property #1","children":[{"id":"S1","title":"tttt","create_event":true}]}]
with a single sample unit created.
After deleting that sample unit, bat api produces
/bat_api/calendar-units?_format=json&types=1&ids=&event_type=availability_hourly&_=1703844559776
- ๐ฎ๐นItaly afagioli Rome
Tested on the upcoming version (post 3.1.0-beta1)
- ๐ช๐ธSpain Carlitus
With the last versiรณn (3.1.0-rc1) i get a different but incomplete result:
[ { "id": "0103", "bat_id": 0, "resourceId": "S103", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0104", "bat_id": 0, "resourceId": "S104", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "092", "bat_id": 0, "resourceId": "S92", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "093", "bat_id": 0, "resourceId": "S93", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "094", "bat_id": 0, "resourceId": "S94", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "095", "bat_id": 0, "resourceId": "S95", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "096", "bat_id": 0, "resourceId": "S96", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "097", "bat_id": 0, "resourceId": "S97", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "098", "bat_id": 0, "resourceId": "S98", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "099", "bat_id": 0, "resourceId": "S99", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0100", "bat_id": 0, "resourceId": "S100", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0101", "bat_id": 0, "resourceId": "S101", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0102", "bat_id": 0, "resourceId": "S102", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0105", "bat_id": 0, "resourceId": "S105", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0106", "bat_id": 0, "resourceId": "S106", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0107", "bat_id": 0, "resourceId": "S107", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0108", "bat_id": 0, "resourceId": "S108", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0109", "bat_id": 0, "resourceId": "S109", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0110", "bat_id": 0, "resourceId": "S110", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0111", "bat_id": 0, "resourceId": "S111", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0112", "bat_id": 0, "resourceId": "S112", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0113", "bat_id": 0, "resourceId": "S113", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0114", "bat_id": 0, "resourceId": "S114", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0115", "bat_id": 0, "resourceId": "S115", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0116", "bat_id": 0, "resourceId": "S116", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0117", "bat_id": 0, "resourceId": "S117", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly" }, { "id": "0118", "bat_id": 0, "resourceId": "S118", "start": "2024-01-04T00:00:00", "end": "2024-01-05T00:00:00", "title": "Disponible", "color": "#009AD8", "blocking": 0, "fixed": 1, "editable": false, "rendering": "background", "type": "availability_hourly"
- ๐ฎ๐นItaly afagioli Rome
Hi!
Can you please confirm the last line of the json output is"type": "availability_hourly"
? - Status changed to Needs work
12 months ago 2:04pm 4 January 2024 - ๐บ๐ธUnited States TolstoyDotCom L.A.
Re #5, this URL:
http://127.0.0.1/drupal1020/web/bat_api/calendar-units?_format=json&types=7&ids=&event_type=availability_hourly&_=1703844559776
Results in this JSON:
{"message":"No route found for \u0022GET http:\/\/127.0.0.1\/drupal1020\/web\/bat_api\/calendar-units\u0022
It's missing the final
"}
Like I said, I'm not familiar with the module. I just installed/enabled it in a new site, I didn't create any content for it.
- ๐ฎ๐นItaly afagioli Rome
trying to fix #12:
what is you open
"http://127.0.0.1/bat_api/calendar-units?_format=json&types=7&ids=&event_type=availability_hourly&_=1703844559776"
(removedrupal1020/web/
)
? - ๐บ๐ธUnited States TolstoyDotCom L.A.
Re #13, that wouldn't work. The "drupal1020" part is because I have multiple local sites, and the "web" part is because I installed Drupal using the standard composer project. If I installed this at the root of its own domain there'd still be the problem (unless the module is doing something really weird).
What I suggest is tracing through a request in a debugger, or removing things until you can pinpoint where the problem is coming from.
Also, I checked Symfony\Component\Serializer\Encoder\JsonEncoder::encode(), which is used to produce the JSON. It's returning correct JSON. Something must be changing it somewhere along the line.
- ๐ฎ๐นItaly afagioli Rome
Well, being the message pretty clear
"message":"No route found "
, I'd suggest to start from that.... - ๐บ๐ธUnited States TolstoyDotCom L.A.
The problem everyone seems to be having is that the end of the JSON is being cut off. Even if the route exists, the JSON is invalid. There's some sort of bug or incompatibility between Drupal 10.2.0 and this module or one of this module's dependencies.
- ๐ฎ๐นItaly afagioli Rome
I see now the json error on #12
{"message":"No route found for \u0022GET http:\/\/127.0.0.1\/drupal1020\/web\/bat_api\/calendar-units\u0022
It's missing the final "}
Thanks for clarifing that
- ๐จ๐ฆCanada g011um Saskatoon
We've been having issues creating nodes via REST/JSONAPI since upgrading to 10.2.0 (10.1.7 worked flawlessly) and in searching for help with that, I came across this issue. Our problem is very similar; we POST data to create a node, and the JSON response returned is missing a few characters at the end, including the final ]} which renders the response invalid.
So I'm wondering your this issue might be related, and if the root cause might not be with bat_api itself, but perhaps something more central to Drupal -- some service/module responsible for HTTP responses, streams or conversion of data to JSON; something that might truncate the response?
It's perhaps a shot in the dark, but I thought I'd mention it, just in case it helped in debugging this issue. Maybe it's not your code that's at fault, maybe it's something in Drupal itself.
- ๐บ๐ธUnited States TolstoyDotCom L.A.
g011um: the bat_api module depends on bat, ctools, fullcalendar_library, hal, and services. Are you using any of those modules? If so, is it possible for you to disable the ones you're using to see if it's one of those modules as opposed to core/vendor?
- ๐จ๐ฆCanada g011um Saskatoon
We're not using bat, fullcalendar or services. We have ctools installed but not enabled. HAL is installed and enabled.
We're primarily making use of JSON:API in core to create nodes from an external script. We do a POST to the "/node" URL, the node is created, but since upgrading from 10.1.7 to 10.2.0 the JSON response we get back is truncated. This seems to happen more frequently if we're creating a node with a formatted text field.
Our issues may not be related, but the fact that we are both seeing truncated JSON responses from Drupal after upgrading to 10.2.0 was enough that I thought I'd mention it.
- ๐ฎ๐นItaly afagioli Rome
testing out:
* Drupal Version 10.2.1
*drush en bat_api
* openhttp://d10.beehotel/a-wrong-path/bat_api/calendar-units?_=1703844559776&_format=json&event_type=availability_hourly&ids=&types=7
* output:{"message":"No route found for \u0022GET http:\/\/d10.beehotel\/a-wrong-path\/bat_api\/calendar-units\u0022"}
(JSON is valid) - ๐ฎ๐นItaly afagioli Rome
- ๐ช๐ธSpain Carlitus
With Drupal 10.2.1 it's the same. And i see that with calendar-units endpoint (/bat_api/calendar-units?_format=json&types=8&ids=&event_type=availability_hourly&_=1704794828919) there is the same problem:
[ { "id": "8", "title": "P2 Lab", "children": [ { "id": "S119", "title": "RNA Extraction Area", "create_event": true }, { "id": "S120", "title": "Hood 16_IRSIQ 05\/029 - Sample Processing", "create_event": true }, { "id": "S121", "title": "Hood 17_IRSIQ 05\/029 - Sample Processing", "create_event": true }, { "id": "S122", "title": "Hood 18_IRSIQ 05\/027", "create_event": true }, { "id": "S123", "title": "Hood 19_IRSIQ 05\/028", "create_event": true }, { "id": "S124", "title": "DNA extraction area 1", "create_event": true }, { "id": "S125", "title": "DNA extraction area 2", "create_event": true }, { "id": "S126", "title": "Hood DNA adition_IRSIQ 05\/024", "create_event": true }, { "id": "S127", "title": "Hood RNA adition_IRSIQ 05\/025", "create_event": true } ]
- ๐บ๐ธUnited States SocialNicheGuru
๐ Conflict with dynamic_entity_reference (DER) 4.x Active
- ๐ช๐ธSpain Carlitus
I get the same result with the last bat_api 3.1RC, the json it's not valid
I'm experiencing quite the same issue as g011um and some others, since upgrading from 10.1 to 10.2 the JSON response we get from our custom resource REST API is truncated (the last closing curly bracket is missing).
I tried returning ResourceResponse with and without cache dependencies, ModifiedResourceResponse and even a basic JSONRepsonse and it always comes out missing the last character.
Maybe it has something the REST API settings or maybe even with the cache settings, but it was working perfectly before the Drupal core upgrade. I'm really clueless now.
Do you guys have resolved your issues yet ?- ๐ช๐ธSpain Carlitus
I have not any file with a php closing tag.
I've a made a core MR, more of a temporal solution, but now it works:
https://www.drupal.org/project/drupal/issues/3432990 ๐ Content-length incorrect and response truncated in web servers Active - ๐ฎ๐นItaly afagioli Rome
How can I reproduce?
Please contribute to the related debug issue https://www.drupal.org/project/bat_api/issues/3433154 ๐ Debug #3411329 ActiveThe very basic structure (not too much stuff.. maybe just what is needed to recreate the issue) of the entity breaking the JSON would help
Thanks - Status changed to Closed: works as designed
8 months ago 6:48am 17 April 2024 - ๐ช๐ธSpain Carlitus
Finnaly i found it!
It's in the bat module, in bat_event.module.
The first line has a whitespace before the opening php tag.
https://git.drupalcode.org/project/bat/-/blob/8.x-2.x/modules/bat_event/...it has
<?php
Instead of
<?php
- ๐ฎ๐นItaly afagioli Rome
ah! Thanks a lot Carlitus
It's my bad really
I must extend the phpcs check to *modules - ๐ฎ๐นItaly afagioli Rome
you have it fixed already in
8.x-10.x
https://git.drupalcode.org/project/bat/-/blob/8.x-10.x/modules/bat_event...
That's why was that difficult to re-create. Better use latest release where possible
- ๐ช๐ธSpain Carlitus
You are right, i don't know why i was using 2.0, sorry.