question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

URIError console warns

See original GitHub issue

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

Issue Analytics

  • State:closed
  • Created 4 years ago
  • Comments:6 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
P0lipcommented, 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.

0reactions
nulltokencommented, Dec 10, 2019

@P0lip 😍

Read more comments on GitHub >

github_iconTop Results From Across the Web

URIError: malformed URI sequence - MDN Web Docs - Mozilla
The JavaScript exception "malformed URI sequence" occurs when URI encoding or decoding wasn't successful.
Read more >
A Definitive Guide to Handling Errors in JavaScript - Kinsta
URIError occurs when a global URI handling function such as decodeURIComponent is used illegally. It usually indicates that the parameter passed ...
Read more >
T168086 jQuery 3 catches all exceptions within promises
If you do not want any console output on these exceptions, set jQuery.Deferred. ... exceptionHook = function (error, stack) { console.warn('jQuery.
Read more >
JavaScript Errors and How to Fix Them - David Walsh Blog
var someVal = null; console.log(someVal.foo); ... Uncaught URIError: URI malformed. Related errors: URIError: malformed URI sequence.
Read more >
encodeURIComponent()
high-low pair ok console.log(encodeURIComponent('\uD800\uDFFF')); // lone high surrogate throws "URIError: malformed URI sequence" ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found