OpenAPITools / OpenAPITools/openapi-generator

[BUG] NPE when inputSpec references non-existing file

Open
#5,760 2 comments 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Issue: Bug
Dominant language
Java
Stars
26.8k
Forks
7.7k
PR merge metrics
PR metrics pending

Description

Using OpenAPI-generator maven-plugin 4.2.3 and an <inputSpec> with a wrong (non-existing) path, instead of failing with a "file not found" error, the plugin crashes with a NPE:

java.lang.NullPointerException
    at java.util.HashSet.<init> (HashSet.java:119)
    at org.openapitools.codegen.config.CodegenConfigurator.toContext (CodegenConfigurator.java:455)
    at org.openapitools.codegen.config.CodegenConfigurator.toClientOptInput (CodegenConfigurator.java:498)
    at org.openapitools.codegen.plugin.CodeGenMojo.execute (CodeGenMojo.java:705)

It's not easy to find the root cause at first sight, and the plugin should check for the existence of the spec file first and report the error properly.

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 with CodegenConfigurator.toContext at line 455 and CodeGenMojo.execute at line 705. Reproduce the Maven-plugin 4.2.3 case using an inputSpec path that does not exist, then verify that it reports a file-not-found error instead of the shown NullPointerException.

Written by the indexing model from the issue text.

Assessment

Tech stack
java
Domain
build-system, tooling
Issue type
Bug
Difficulty
2/5
Estimated time
1-3 hours
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
35/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.