To re-create:
The error happens in loadNamedProfile() when promptCredentials() is calling it. The type is undefined so the condition is not met.
public loadNamedProfile(name: string, type?: string): IProfileLoaded {
for (const profile of this.allProfiles) {
if (profile.name === name && (type ? profile.type === type : true)) {
return profile;
}
}
throw new Error(localize("loadNamedProfile.error.profileName", "Could not find profile named: ")
+ name + localize("loadNamedProfile.error.period", "."));
}
@Colin-Stone @phaumer Can you please help me understand the code?
if (profile.name === name && (type ? profile.type === type : true)) {
return profile;
}
@jellypuno the method parameter type is optional, so if it is provided it will use it as a filter and only search in profiles of that type; if it is not provided it will just return the first profile of that name it will find of any type, which is typically zosmf as that is the first type that get registered in the extensibility registry. Other types will follow after. Generally, we want to recommend to define profiles with unique names to avoid confusion, but the CLI allows defining zosmf and zftp profiles with the same name.
I am not sure what error you are seeing. Can you add the exact error message to this issue? It should not be possible to create a profile without a type.
Fix was added in #525
I tried to fix this by adding trim() in the name passed toloadNamedProfile() but I am still having an error if I create a profile with spaces in the end.
To Re-Create this error:
sample )Note: To prevent users from creating profiles with spaces, I will add a trim here:
chosenProfile = profileName.trim();
But the error will still appear if they have existing profiles with spaces.
Until we implement the ability to update/delete profiles from within the extension, I'm afraid the only workaround for users that already have profiles with spaces is to create new ones (and manually delete old ones if they wanted to). :cry:
Most helpful comment
@jellypuno the method parameter
typeis optional, so if it is provided it will use it as a filter and only search in profiles of that type; if it is not provided it will just return the first profile of that name it will find of any type, which is typically zosmf as that is the first type that get registered in the extensibility registry. Other types will follow after. Generally, we want to recommend to define profiles with unique names to avoid confusion, but the CLI allows defining zosmf and zftp profiles with the same name.I am not sure what error you are seeing. Can you add the exact error message to this issue? It should not be possible to create a profile without a type.