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

Failed validation: #/definitions/SearchResult (new "screenerFieldResults" etc from Yahoo) #255

Closed
aronrodrigues opened this issue Aug 10, 2021 · 3 comments
Labels
bug Something isn't working validation Issues related to validation

Comments

@aronrodrigues
Copy link

Validation Error

Minimal Reproduction

y2.search("AMZN").then(d=> d.quotes);

Symbol(s) that it happened for

  • AMZN

Error Message

> The following result did not validate with schema: #/definitions/SearchResult
[
  {
    instancePath: '',
    schemaPath: '#/additionalProperties',
    keyword: 'additionalProperties',
    params: { additionalProperty: 'screenerFieldResults' },
    message: 'must NOT have additional properties'
  },
  {
    instancePath: '',
    schemaPath: '#/additionalProperties',
    keyword: 'additionalProperties',
    params: { additionalProperty: 'timeTakenForScreenerField' },
    message: 'must NOT have additional properties'
  }
]

This may happen intermittently and you should catch errors appropriately.
However:  1) if this recently started happening on every request for a symbol
that used to work, Yahoo may have changed their API.  2) If this happens on
every request for a symbol you've never used before, but not for other
symbols, you've found an edge-case.  Please see if anyone has reported
this previously:

  https://github.com/gadicc/node-yahoo-finance2/issues?q=is%3Aissue+Failed%20validation%3A%20%23%2Fdefinitions%2FSearchResult

or open a new issue (and mention the symbol):

  https://github.com/gadicc/node-yahoo-finance2/issues/new?labels=bug%2C+validation&template=validation.md&title=Failed%20validation%3A%20%23%2Fdefinitions%2FSearchResult

For information on how to turn off the above logging or skip these errors,
see https://github.com/gadicc/node-yahoo-finance2/tree/devel/docs/validation.md.

Uncaught FailedYahooValidationError: Failed Yahoo Schema validation
    at Object.validate [as default] (/Users/aronrodrigues/workspace/tribie-app/functions/node_modules/yahoo-finance2/dist/cjs/src/lib/validateAndCoerceTypes.js:194:15) {
  result: {
    explains: [],
    count: 10,
    quotes: [ [Object], [Object], [Object], [Object], [Object], [Object] ],
    news: [ [Object], [Object], [Object], [Object] ],
    nav: [],
    lists: [],
    researchReports: [],
    screenerFieldResults: [],
    totalTime: 83,
    timeTakenForQuotes: 478,
    timeTakenForNews: 700,
    timeTakenForAlgowatchlist: 400,
    timeTakenForPredefinedScreener: 400,
    timeTakenForCrunchbase: 400,
    timeTakenForNav: 400,
    timeTakenForResearchReports: 0,
    timeTakenForScreenerField: 0
  },
  errors: [
    {
      instancePath: '',
      schemaPath: '#/additionalProperties',
      keyword: 'additionalProperties',
      params: [Object],
      message: 'must NOT have additional properties'
    },
    {
      instancePath: '',
      schemaPath: '#/additionalProperties',
      keyword: 'additionalProperties',
      params: [Object],
      message: 'must NOT have additional properties'
    }
  ]
}


// Returned quotes:
[
    {
      exchange: 'NMS',
      shortname: 'Amazon.com, Inc.',
      quoteType: 'EQUITY',
      symbol: 'AMZN',
      index: 'quotes',
      score: 31857500,
      typeDisp: 'Equity',
      longname: 'Amazon.com, Inc.',
      isYahooFinance: true
    },
    {
      exchange: 'MEX',
      shortname: 'AMAZON COM INC',
      quoteType: 'EQUITY',
      symbol: 'AMZN.MX',
      index: 'quotes',
      score: 20328,
      typeDisp: 'Equity',
      longname: 'Amazon.com, Inc.',
      isYahooFinance: true
    },
    {
      exchange: 'NEO',
      shortname: 'AMAZON.COM CDR (CAD HEDGED)',
      quoteType: 'EQUITY',
      symbol: 'AMZN.NE',
      index: 'quotes',
      score: 20152,
      typeDisp: 'Equity',
      isYahooFinance: true
    },
    {
      exchange: 'BUE',
      shortname: 'AMAZON COM INC',
      quoteType: 'EQUITY',
      symbol: 'AMZN.BA',
      index: 'quotes',
      score: 20064,
      typeDisp: 'Equity',
      longname: 'Amazon.com, Inc.',
      isYahooFinance: true
    },
    {
      exchange: 'OPR',
      shortname: 'AMZN Aug 2021 3300.000 put',
      quoteType: 'OPTION',
      symbol: 'AMZN210813P03300000',
      index: 'quotes',
      score: 20026,
      typeDisp: 'Option',
      isYahooFinance: true
    },
    {
      exchange: 'OPR',
      shortname: 'AMZN Aug 2021 3400.000 call',
      quoteType: 'OPTION',
      symbol: 'AMZN210813C03400000',
      index: 'quotes',
      score: 20025,
      typeDisp: 'Option',
      isYahooFinance: true
    }
  ]

Environment

Node
Node version 16.5.0
Npm version: 6.14.13
Library version 1.14.3

Additional Context

@aronrodrigues aronrodrigues added bug Something isn't working validation Issues related to validation labels Aug 10, 2021
@gadicc
Copy link
Owner

gadicc commented Aug 11, 2021

Hey @aronrodrigues, thanks for reporting. Looks like Yahoo just added this field. This is fixed in our devel branch, but since it's very new, I'm not releasing yet until we've had a little more experience with it.

@gadicc
Copy link
Owner

gadicc commented Aug 11, 2021

In particular, we're accepting { screenerFieldResults?: Array<any>; } since we have no data yet on what this new field is meant to contain.

@gadicc gadicc changed the title Failed validation: #/definitions/SearchResult Failed validation: #/definitions/SearchResult (new "screenerFieldResults" etc from Yahoo) Aug 11, 2021
gadicc pushed a commit that referenced this issue Aug 12, 2021
## [1.14.4](v1.14.3...v1.14.4) (2021-08-12)

### Bug Fixes

* **quoteSummary:** sellingGeneralAdministrative (fixes [#258](#258)) ([c01fe74](c01fe74))
* **search:** add support for screener fields ([#255](#255)) ([2b23ccb](2b23ccb))
@gadicc
Copy link
Owner

gadicc commented Aug 12, 2021

Hey @aronrodrigues, v1.14.4 partially fixes this, so that it no longer throws an error, but we still don't actually know what this data looks like. Will track further developments in #259, but closing at least this validation error for now. Thanks again for reporting!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working validation Issues related to validation
Projects
None yet
Development

No branches or pull requests

2 participants