OpenAPITools / OpenAPITools/openapi-generator

Consider limiting message size for exceptions thrown from DefaultGenerator.processOperation

Open Beginner friendly
#22,557 0 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Enhancement: Feature
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

I was given a large 40 000 line spec with a few hundred operations, where a single operation had a query parameter with empty name. Naturally, the generator threw.

Trying to be helpful, the exception message contains the entire schema. For a 40 000 line spec, that schema is massive. It completely overruns my console, losing the actual error information in the process.

Suggestion: Put a limit on the schema length when constructing the exception message. Take the first 10000 chars of the schema or something. Or maybe reorder the message and put the schemas first such that when the message gets cut off, the short descriptors (operation name, tag, resource) remain available

The offending line:
https://github.com/OpenAPITools/openapi-generator/blob/f484aeac2c067d018eeea6f286d32619b21c60e3/modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java#L1603

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start at modules/openapi-generator/src/main/java/org/openapitools/codegen/DefaultGenerator.java around line 1603, where DefaultGenerator.processOperation constructs the exception message. Reproduce the failure with a large OpenAPI specification and an operation whose query parameter has an empty name. Done means the exception no longer overwhelms console output while retaining useful operation details such as the operation name, tag, or resource.

Written by the indexing model from the issue text.

Assessment

Tech stack
java, openapi
Domain
api, tooling
Issue type
Feature
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
62/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.