Skip to content

Bug: R Code Generation Does Not Quote Parameters with Special Characters (e.g., codes[]) #379

@abansal21

Description

@abansal21

When using the library to convert an HTTP request into an R code snippet, parameters with special characters (such as codes[] or demo-param) are not being quoted correctly in the generated R code. This causes an error in R because such parameters are not valid without quotes.

In R, certain special characters like [], -, and others are not valid in unquoted object names. As a result, the generated R code fails to execute properly when using such parameters.

I also saw a test case at "https://github.com/Kong/httpsnippet/blob/master/src/targets/r/httr/fixtures/nested.r" which doesn't run in R,
it gives following error

Error: unexpected '=' in:
"queryString <- list(
  foo[bar] ="
Execution halted

Instead it should be like this to run correctly and avoid any special character issues.

queryString <- list(
  `foo[bar]` = "baz,zap",
  `fiz` = "buz"
)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    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