Skip to content

Generated terraform provider doesn't urlencode path parameters #1369

Open
@anttiviljami

Description

@anttiviljami

Minimal reproduction

# openapi.yml
openapi: 3.0.0
info: 
  title: Minimal Speakeasy Path Param Encoding Bug Repro
  version: 0.0.1
servers:
  - url: http://localhost:8080
paths:
  /files/{id}:
    get:
      x-speakeasy-entity-operation: File#get
      operationId: getFileByName
      description: Gets a file by name
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      responses:
        200:
          description: File
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/File'
    put:
      x-speakeasy-entity-operation: File#create,update
      operationId: createOrUpdateFile
      description: Creates or updates a file
      parameters:
        - name: id
          in: path
          required: true
          schema:
            type: string
      requestBody:
        required: true
        content:
          application/json:
            schema:
              $ref: '#/components/schemas/File'
      responses:
        200:
          description: File
          content:
            application/json:
              schema:
                $ref: '#/components/schemas/File'
components:
  schemas:
    File:
      x-speakeasy-entity: File
      type: object
      properties:
        id:
          type: string
# resource.tf
resource "demo-file_file" "my_file" {
  id = "Should/Be%Encoded"
}
$ terraform init
$ terraform apply
Terraform used the selected providers to generate the following execution plan. Resource actions are indicated with the
following symbols:
  + create

Terraform will perform the following actions:

  # demo-file_file.my_file will be created
  + resource "demo-file_file" "my_file" {
      + id = "Should/Be%Encoded"
    }

Plan: 1 to add, 0 to change, 0 to destroy.

Do you want to perform these actions?
  Terraform will perform the actions described above.
  Only 'yes' will be accepted to approve.

  Enter a value: yes

demo-file_file.my_file: Creating...
╷
│ Error: failure to invoke API
│ 
│   with epilot-file_file.my_file,
│   on resource.tf line 1, in resource "demo-file_file" "my_file":
│    1: resource "demo-file_file" "my_file" {
│ 
│ error creating request: parse "http://localhost:8080/files/Should/Be%Encoded": invalid URL escape "%En"

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions