Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

NullPointerException when loading remote reference. #1357

Open
tkrop opened this issue Feb 9, 2022 · 1 comment
Open

NullPointerException when loading remote reference. #1357

tkrop opened this issue Feb 9, 2022 · 1 comment
Labels
area: server Zally server issues type: bug

Comments

@tkrop
Copy link
Member

tkrop commented Feb 9, 2022

Following simple API example

openapi: 3.0.0
info:
  x-api-id: 10eab089-30d0-4dd1-9be7-2948c322b82b
  x-audience: company-internal
  version: "0.1.0"
  title: "My API"

paths:
  /test:
    get:
      responses:
        200:
          description: test
          content:
            application/json:
              schema:
                type: object
                properties:
                    id:
                      type: string
                      format: uuid
                    created_at:
                      type: string
                      format: date-time
      parameters:
        - $ref: 'https://infrastructure-api-repository.zalandoapis.com/apis/401d47fe-1628-4bea-8243-32f45ce9913d/versions/1.0.1/revisions/6#/parameters/Consents'

loads a valid external reference that should work but creates creates a 500 - Internal Server Error response:

{
    "title":"Internal Server Error",
    "status":500,
    "detail":"check invocation failed: id=Z001 title=Path parameters validation checkName=checkSchemaOrContentProperty reason=java.lang.NullPointerException: parameter.name must not be null"
}

The details of the stack trace are

java.lang.RuntimeException: check invocation failed: id=Z001 title=Path parameters validation checkName=checkSchemaOrContentProperty reason=java.lang.NullPointerException: parameter.name must not be null
        at org.zalando.zally.core.RulesValidator.invoke(RulesValidator.kt:63) ~[zally-core-2.1.1-SNAPSHOT.jar!/:na]
        at org.zalando.zally.core.RulesValidator.validate(RulesValidator.kt:40) ~[zally-core-2.1.1-SNAPSHOT.jar!/:na]
        at org.zalando.zally.core.CompositeRulesValidator.validate(CompositeRulesValidator.kt:9) ~[zally-core-2.1.1-SNAPSHOT.jar!/:na]
        at org.zalando.zally.apireview.ApiViolationsController.validate(ApiViolationsController.kt:47) ~[classes!/:na]
        at jdk.internal.reflect.GeneratedMethodAccessor262.invoke(Unknown Source) ~[na:na]
...
Caused by: java.lang.NullPointerException: parameter.name must not be null
        at org.zalando.zally.ruleset.zally.PathParameterRule.checkSchemaOrContentProperty(PathParameterRule.kt:47) ~[zally-ruleset-zally-2.1.1-SNAPSHOT.jar!/:na]
        ... 98 common frames omitted

The failure looks like an authorization problem, however, while on first sight the referenced location looks fine, it contains another local reference that may create problems:

in: body
name: body
description: "Consent object"
required: true
schema:
  $ref: "#/definitions/Consents"

The problem here is that in: body is not allowed in this parameter list. Consequently, the parser seems to filter resulting in an empty parameter array element, which results in a null-name as the NPE is telling. Note: referencing in: query parameter is working fine, e.g. Services.

@tkrop tkrop added type: bug area: server Zally server issues labels Feb 9, 2022
@vadeg
Copy link
Contributor

vadeg commented Feb 15, 2022

@tkrop given that definitions field mentioned here

schema:
  $ref: "#/definitions/Consents"

doesn't exist in OpenAPI 3.0, but exist in Swagger 2.0 does this means that the referenced API uses Swagger 2.x?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: server Zally server issues type: bug
Projects
None yet
Development

No branches or pull requests

2 participants