@@ -89,24 +89,24 @@ function usesBasicForIam(obj: any): boolean {
8989 return obj . username === 'apikey' && ! obj . password . startsWith ( 'icp-' ) ;
9090}
9191
92- // returns true if the string has a { or " as the first character
92+ // returns true if the string has a curly bracket or quote as the first or last character
9393// these are common user-issues that we should handle before they get a network error
94- function badFirstChar ( value : string ) : boolean {
95- return value . startsWith ( '{' ) || value . startsWith ( '"' ) ;
94+ function badCharAtAnEnd ( value : string ) : boolean {
95+ return value . startsWith ( '{' ) || value . startsWith ( '"' ) || value . endsWith ( '{' ) || value . endsWith ( '"' ) ;
9696}
9797
98- // checks credentials for common user mistakes of copying { or " characters from the documentation
98+ // checks credentials for common user mistakes of copying {, }, or " characters from the documentation
9999function checkCredentials ( obj : any ) {
100100 let errorMessage = '' ;
101101 const credsToCheck = [ 'url' , 'username' , 'password' , 'iam_apikey' ] ;
102102 credsToCheck . forEach ( cred => {
103- if ( obj [ cred ] && badFirstChar ( obj [ cred ] ) ) {
104- errorMessage += `${ cred } starts with a bad character. ` ;
103+ if ( obj [ cred ] && badCharAtAnEnd ( obj [ cred ] ) ) {
104+ errorMessage += `The ${ cred } shouldn't start or end with curly brackets or quotes. Be sure to remove any {, }, or " ` ;
105105 }
106106 } ) ;
107107
108108 if ( errorMessage . length ) {
109- errorMessage += 'Revise these credentials - they should not start with a { or " ' ;
109+ errorMessage += 'Revise these credentials - they should not start or end with curly brackets or quotes. ' ;
110110 return errorMessage ;
111111 } else {
112112 return null ;
0 commit comments