I found out that when setting OPTIC_TOKEN, the commands that depend on downloading standards from Optic breaks.
Bonus: despite the WARNING message, it fails the exit code so the messaging is a bit confusing.
To Reproduce
run optic login to get yourself a personal access token
run optic lint docs/openapi/openapi.yaml to prove it passes
run export OPTIC_TOKEN=$(jq -r .token ~/.config/optic/config.json) to simulate what our CI does in place of having the file
run optic lint docs/openapi/openapi.yaml again to prove it doesn't work
Funny enough, it works in CircleCI, but fails when I want to run it locally on my PC (matching the command between CI and local)
❯ LOG_LEVEL=debug optic lint docs/openapi/openapi.yaml
Using Optic version 0.54.12 - npm/yarn
{
isDefaultConfig: true,
root: '/home/balint/git/buyback-funnel',
configPath: undefined,
ruleset: undefined,
isAuthenticated: true,
client: OpticBackendClient {
fetch: [AsyncFunction: fetch],
source: 'optic',
handleJsonResponse: [AsyncFunction: handleJsonResponse],
baseUrl: 'https://api.useoptic.com',
getAuthToken: [Function (anonymous)]
},
isInCi: false,
authenticationType: 'env',
userId: 'my-secret-token=',
vcs: {
type: 'git',
sha: '9043c0fa880ecee0521ada7e7723e7e9511ed431',
diffSet: Set(0) {}
}
}
Linting spec docs/openapi/openapi.yaml...
Initializing rule runner with the following options
{
options: {
rulesetArg: undefined,
specRuleset: '@back-market/back-market-primary-standard',
config: {
isDefaultConfig: true,
root: '/home/balint/git/buyback-funnel',
configPath: undefined,
ruleset: undefined,
isAuthenticated: true,
client: [OpticBackendClient],
isInCi: false,
authenticationType: 'env',
userId: 'my-secret-token=',
vcs: [Object]
},
specVersion: '3.1.x'
},
checksEnabled: true
}
Warning: Could not download standard @back-market/back-market-primary-standard. Please check the ruleset name and whether you are authenticated (run: optic login).
{ standard: [] }
{ rulesToFetch: [], localRulesets: {}, hostedRulesets: {} }
✔ OpenAPI is valid
~/git/buyback-funnel main !1 ············································································································································· ▼ 3.12.0 Py 20.11.0 Node 17:18:03
❯
Expected behavior
I expect the two runs to behave exactly the same.
Screenshots
N/A
Details (please complete the following information):
OS and version: 22.04.1-Ubuntu
Optic version: v0.54.12
NodeJS version: v20.11.0
Additional context
I'm developing a workflow where I'm using the official docker container that has both optic and spectral.
I originally blamed docker for this (networking, or env variables etc), but then I ran it in my shell directly and it produced the same issue.
Describe the bug
I found out that when setting
OPTIC_TOKEN
, the commands that depend on downloading standards from Optic breaks.Bonus: despite the
WARNING
message, it fails the exit code so the messaging is a bit confusing.To Reproduce
optic login
to get yourself a personal access tokenoptic lint docs/openapi/openapi.yaml
to prove it passesexport OPTIC_TOKEN=$(jq -r .token ~/.config/optic/config.json)
to simulate what our CI does in place of having the fileoptic lint docs/openapi/openapi.yaml
again to prove it doesn't workFunny enough, it works in CircleCI, but fails when I want to run it locally on my PC (matching the command between CI and local)
Expected behavior I expect the two runs to behave exactly the same.
Screenshots N/A
Details (please complete the following information):
Additional context I'm developing a workflow where I'm using the official docker container that has both
optic
andspectral
. I originally blamed docker for this (networking, or env variables etc), but then I ran it in my shell directly and it produced the same issue.