Template name "" is not valid after upgrade to Symfony2.3 #518

priestor opened this Issue Aug 1, 2013 · 14 comments


None yet

5 participants

priestor commented Aug 1, 2013

Hello Folks!

I've updated to Symfony 2.3 and now my RestBundle doesn't work as it did before.

This an example of my code:

    $view = View::create()

    $context = new SerializationContext();
    $context->setGroups(array('list_detail', 'list'));


This did the job, giving me a nice and clean json output.

But now I'm getting that error:
"Template name "" is not valid (format is "bundle:section:template.format.engine").
500 Internal Server Error - InvalidArgumentException"

This is the config:
default_format: json
json: ['application/json; charset=UTF-8', 'application/json']
view_response_listener: false
failed_validation: HTTP_BAD_REQUEST
default_engine: php
json: true
prefer_extension: false
json: fos_rest.decoder.json

using these packages:
"jms/serializer": "0.13.@dev",
"jms/serializer-bundle": "0.12.
"friendsofsymfony/rest-bundle": "0.13.*@dev",

Any clue what causes this problem? :(
Thank you!

lsmith77 commented Aug 2, 2013

can you pastebin your request on the HTTP level?


My problem might be related. Any help will be greatly appreciated!

Since upgrading to 2.3.2



I managed to resolve mine by setting the listener to false:

stackoverflow updated

lsmith77 commented Aug 4, 2013

the issue is likely not caused by Symfony2.3 but by using the latest master version of FOSRestBundle that switched to a different library for content negotiation

/cc @willdurand


The only issue I can see here is that _format is not handled, but I don't know why. IMO there is nothing wrong except the use of _format itself...

priestor commented Aug 5, 2013

Hello, sorry for the delay.
It was a realy urgent issue in my case. I had to use a backup of an old stage and just updated the serializer packages. So it runs again as it should.

But the issue is still there. What excacly do you mean by "_format is not handled"?



You set prefer_extension to false, so there is no issue here. Look at your Accept header and you will see that rendering html makes the most sense in your case. Turn prefer_extension to true if you want to get JSON again.




Hi I'm sorry could not find some time to set up a playground with the state of the issue. I'm trying but the days still have only 24h :)


@lsmith77 same error with 0.12.0

"jms/serializer-bundle": "dev-master",
"friendsofsymfony/rest-bundle": "0.12.*@dev",

Then latest master version of FOSRestBundle that switched to a different library for content negotiation does not seem to be the problem at his own

Hope it helps


The issue is the accept header. you must either send application/json; charset=UTF-8 or application/json as the Accept header in your request


Alternatively prefer_extension needs to be enabled and then you can simply add a .json to your route pattern.


OK maybe some cache after modifying the fos rest version in composer.json.
All working as expected.

@lsmith77 lsmith77 closed this Aug 13, 2013
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment