zowe-cli
zowe-cli copied to clipboard
Failed to load schema for profile type `sample` when default doesn't exist
Again similar to zowe/imperative#645. However, both a zowe.config.json
and zowe.schema.json
exist. However, if zowe.config.json
specifies a default that doesn't exist, you get an error that the schema failed to load.
{
"$schema": "./zowe.schema.json",
"profiles": {
},
"defaults": {
"sample": "sample"
},
"plugins": []
}
However, the error seems misleading, since the schema exists.
Here is what the error may look like
ProfInfoErr: Failed to load schema for profile type sample
at ProfileInfo.mergeArgsForProfile (~/node_modules/@zowe/imperative/src/config/src/ProfileInfo.ts:803:19)
at ~/test.ts:21:31 {
mDetails: {
errorCode: 'LoadSchemaFailed',
msg: 'Failed to load schema for profile type sample'
},
mMessage: 'Failed to load schema for profile type sample',
mItemsInError: []
}
And here is a sample script to test with
import { ImperativeError, ProfileInfo } from "@zowe/imperative";
(async () => {
const profInfo = new ProfileInfo("zowe");
await profInfo.readProfilesFromDisk();
const profAttrs = profInfo.getDefaultProfile("sample");
if (profAttrs == null) throw new ImperativeError({ msg: "Default profile not found" })
// The issue happens when here : )
profInfo.mergeArgsForProfile(profAttrs, { getSecureVals: true });
})().catch((err) => {
console.error(err);
process.exit(1);
});