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

URIError console warns #658

Closed
nulltoken opened this issue Oct 9, 2019 · 6 comments · Fixed by #685
Closed

URIError console warns #658

nulltoken opened this issue Oct 9, 2019 · 6 comments · Fixed by #685
Assignees
Labels
p/medium sev/major t/bug Something isn't working

Comments

@nulltoken
Copy link
Contributor

Describe the bug

Linting a file that references another external file over http fills the console with unexpected warnings.

To Reproduce

  1. Given these OpenAPI document '...'

repo/ruleset.yaml

extends:
  - [spectral:oas, off]

rules:
  schema-strings-maxLength:
    type: validation
    severity: warn
    recommended: true
    message: "String typed properties MUST be further described using 'maxLength'. Error: {{error}}"
    given: $..*[?(@.type === 'string')]
    then:
      field: maxLength
      function: truthy

repro/URIError.yaml

%YAML 1.2
---
openapi: 3.0.0

info:
  title: Hey Mum! I'm on GitHub!
  description: Resource definition.
  version: 1.0.0

servers:
  - url: https://boom.com

paths:
  "/test":
    get:
      summary: Dummy endpoint.
      description: Cf. summary
      responses:
        "200":
          description: All is good.
          content:
            application/json:
              schema:
                type: string
        "400":
          description: Bad Request.
          content:
            application/json:
              schema:
                $ref: "#/components/schemas/Error"
components:
  schemas:
    Error:
      $ref: https://REDACTED/static/schemas/common/v2/library.openapi.yaml#/components/schemas/Error

https://REDACTED/static/schemas/common/v2/library.openapi.yaml

%YAML 1.2
---
openapi: 3.0.0

info:
  title: Library
  description: Collection of reusable standard definitions.
  version: 2.0.0
paths: {}
components:
  schemas:

...trimmed...

    Error:
      type: object
      properties:
        error:
          type: string
        error_description:
          type: string
        status_code:
          type: string

...trimmed...
  1. Run this CLI command '....'
$ yarn spectral lint --ruleset ./repro/ruleset.yaml ./repro/URIError.yaml
yarn run v1.15.2
$ C:\REDACTED\node_modules\.bin\spectral lint --ruleset ./repro/ruleset.yaml ./repro/URIError.yaml
OpenAPI 3.x detected
Encountered error when running rule 'schema-strings-maxLength' on node at path '$,paths,/test,get,responses,400,content,app
lication/json,schema,properties,error':
URIError: Invalid JSON Pointer syntax; URI fragment identifiers must begin with a hash.
Encountered error when running rule 'schema-strings-maxLength' on node at path '$,paths,/test,get,responses,400,content,app
lication/json,schema,properties,error_description':
URIError: Invalid JSON Pointer syntax; URI fragment identifiers must begin with a hash.
Encountered error when running rule 'schema-strings-maxLength' on node at path '$,paths,/test,get,responses,400,content,app
lication/json,schema,properties,status_code':
URIError: Invalid JSON Pointer syntax; URI fragment identifiers must begin with a hash.

c:/REDACTED/repro/URIError.yaml
 23:22  warning  schema-strings-maxLength  String typed properties MUST be further described using 'maxLength'. Error: path
s./test.get.responses.200.content.application/json.schema.maxLength is not truthy

https://REDACTED/static/schemas/common/v2/library.openapi.yaml
 65:15  warning  schema-strings-maxLength  String typed properties MUST be further described using 'maxLength'. Error: components.schemas.Error.properties.error.maxLength is not truthy
 67:27  warning  schema-strings-maxLength  String typed properties MUST be further described using 'maxLength'. Error: components.schemas.Error.properties.error_description.maxLength is not truthy
 69:21  warning  schema-strings-maxLength  String typed properties MUST be further described using 'maxLength'. Error: components.schemas.Error.properties.status_code.maxLength is not truthy

✖ 4 problems (0 errors, 4 warnings, 0 infos, 0 hints)

error Command failed with exit code 1.
info Visit https://yarnpkg.com/en/docs/cli/run for documentation about this command.
  1. See error

The console is filled up with unexpected warnings URIError: Invalid JSON Pointer syntax; URI fragment identifiers must begin with a hash.

Expected behavior
No warnings ;-)

Environment (remove any that are not applicable):

  • Library version: 4.2.0
  • OS: Windows 7
@nulltoken nulltoken added the t/bug Something isn't working label Oct 9, 2019
@nulltoken
Copy link
Contributor Author

@philsturgeon Hey! Have you had the chance the repro the issue and/or triage it?

I understand this might not be a high priority as this doesn't prevent Spectral from working, but those warnings greatly reduce the readability of the produced log and make it far more difficult to go through.

@P0lip
Copy link
Contributor

P0lip commented Oct 15, 2019

@nulltoken taking a look 👀

No warnings ;-)

It's actually a slight regression introduced in 4.2. Going to fix it and perhaps release a patch version once the fix is merged.

@philsturgeon
Copy link
Contributor

@nulltoken sorry for the delay, this is definitely something that needs fixing sooner rather than later. It's the thick of conference season so im slow at replying, but the team are on point as always! :D

@P0lip this seems like something which might have been hidden through --silent. Can we investigate other ways to silence the log output which was annoying us? Doesn't need to be done now, just keep it in mind. Either way im sure you can solve this regression easily enough!

@nulltoken
Copy link
Contributor Author

@P0lip Do you think this could be part of the next 5.0 release?

@P0lip
Copy link
Contributor

P0lip commented Nov 21, 2019

@nulltoken this will be a part of the next release, word.

@nulltoken
Copy link
Contributor Author

@P0lip 😍

@nulltoken nulltoken mentioned this issue Dec 12, 2019
4 tasks
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
p/medium sev/major t/bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants