Skip to content

Extra Spaces Returned in Value From HttpResponse Command #6869

@briankalwat

Description

@briankalwat

Description

If a merge field is used together with a string literal in a {% httpresponse %}[[ header ]] value, it causes one or more extra space characters to be returned, which breaks the intended functionality.

We had a language model analyze the code and it indicated that the issue is likely in Rock/Lava/Blocks/HttpResponse.cs:53 because it’s splitting the string every {{ }} / {% %} boundary, and then joining them back with a space between them. Later, Rock/Lava/Blocks/HttpResponse.cs:181 is running .Trim() but that only removes the extra spaces at the beginning and end of the string, not the extra spaces between the pieces.



Other commands like {% observe %} appear to do the join using string.Empty instead of a space.



The example we were using when we encountered this issue was:

{% httpresponse %}
    [[ header key:'HX-Replace-Url' ]]/groups/search?campus={{ campus.IdKey }}[[ endheader ]]
{% endhttpresponse %}

Actual Behavior

The above template returns /groups/search?campus=%20abc12345 (note the %20 which is an encoded space after the equals sign – that shouldn’t be there).

Expected Behavior

The template should return /groups/search?campus=abc12345 instead, with no space after the =

Steps to Reproduce

  1. In a Lava Application, use the {% httpresponse %} command and include a Lava Merge field in the value.

  2. Call the endpoint using HTMX or something like PostMan, to see what value is returned in the key you provided.

  3. Note that an extra space is added between each merge field(s) you used.

  4. Modify the template so it assigns the entire value first and then uses it. When you run that template, no extra spaces are added. For example:

{% assign path = '/groups/search?campus=' | Append:campus.IdKey %}

{% httpresponse %}
    [[ header key:'HX-Replace-Url' ]]{{ path }}[[ endheader ]]
{% endhttpresponse %}

Issue Confirmation

  • Perform a search on the Github Issues to see if your bug is already reported.
  • Reproduced the problem on a fresh install or on the demo site.

Rock Version

At least v18.1 through prealpha 20.0.3

Client Culture Setting

en-US

Metadata

Metadata

Assignees

No one assigned

    Labels

    Fixed in v19.2Status: ConfirmedIt's clear what the subject of the issue is about, and what the resolution should be.Topic: LavaRelated to the Lava templating language.Type: BugConfirmed bugs or reports that are very likely to be bugs.

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions