opticdev / optic

OpenAPI linting, diffing and testing. Optic helps prevent breaking changes, publish accurate documentation and improve the design of your APIs.
https://useoptic.com
MIT License
1.36k stars 83 forks source link

Cannot use diff-all offline #2723

Closed jgresty closed 9 months ago

jgresty commented 9 months ago

Describe the bug Trying to run diff-all without setting an OPTIC_TOKEN results in the error:

Error making request to Optic
It looks like your token is invalid (this could mean your token has expired, or it has been revoked).

To Reproduce Steps to reproduce the behavior:

  1. unset OPTIC_TOKEN
  2. Run diff-all

Expected behavior Optic will diff specs without calling out to the web service.

Details (please complete the following information):

Additional context It appears that an exception is thrown when looking up generatedDetails, partial trace:

    at handleJsonResponse (@useoptic/optic/build/client/JsonHttpClient.js:32:15)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async getOrganizationFromToken (@useoptic/optic/build/utils/organization.js:17:7)
    at async getDetailsForGeneration (@useoptic/optic/build/utils/generated.js:19:18)
    at async computeAll (@useoptic/optic/build/commands/diff/diff-all.js:152:28)

This issue was masked behind the --generated flag prior to v0.48.10-0 however that version made this option always enabled.

niclim commented 9 months ago

A fix is included as part of 0.54.4 - it should avoid calling out if there's no token set - let me know if there's anything else we can help with!