Skip to content

specs: type: file responses cause temp file leaks #138

@jmdelafe

Description

@jmdelafe

The spec defines several GET endpoints with schema: { type: file } in their 200 responses:

# Example: /services/haproxy/storage/maps/{name}
get:
  operationId: getOneStorageMap
  produces:
    - application/octet-stream
  responses:
    "200":
      description: Successful operation
      schema:
        type: file    # <-- causes *os.File + temp file in Go client

When consumed by the OpenAPI Generator Go client, type: file maps to *os.File. The generated decode() function creates a temporary file on disk (os.CreateTemp) for every API response, but never cleans it up. Over time, this accumulates thousands of files in /tmp.

Suggestion

These endpoints return text content (map files, crt lists). Consider changing the response schema to type: string or type: string with format: binary, which would let Go clients receive the content directly without temp files.

Alternatively, if type: file is intentional, it may be worth documenting that generated clients require callers to explicitly delete the returned file after use.

Why

Each call to these endpoints leaks a temp file. For applications that poll or sync map files frequently, this can fill /tmp on long-running processes.

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