zowe-cli icon indicating copy to clipboard operation
zowe-cli copied to clipboard

Failed to load schema for profile type `sample` when default doesn't exist

Open dkelosky opened this issue 3 years ago • 1 comments

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.

dkelosky avatar Jul 28 '21 16:07 dkelosky

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);
});

zFernand0 avatar Nov 17 '23 18:11 zFernand0