{"record":{"id":"9b359190d96bd682","repo":"pentaho/pentaho-kettle","slug":"failed-to-parse-sso-provider-response","errorCode":null,"errorMessage":"Failed to parse SSO provider response","messagePattern":"Failed to parse SSO provider response","errorType":"exception","errorClass":"IOException","httpStatus":null,"severity":"error","filePath":"plugins/repositories/core/src/main/java/org/pentaho/di/ui/repo/util/SsoProviderService.java","lineNumber":75,"sourceCode":"        if ( !( parsed instanceof JSONArray providersArray ) ) {\n          return Collections.emptyList();\n        }\n\n        List<SsoProvider> providers = new ArrayList<>();\n        for ( Object item : providersArray ) {\n          if ( item instanceof JSONObject providerObject ) {\n            boolean enabled = getBoolean( providerObject.get( \"enabled\" ) );\n            String clientName = stringValue( providerObject.get( \"clientName\" ) );\n            String authorizationUri = stringValue( providerObject.get( \"authorizationUri\" ) );\n            String registrationId = stringValue( providerObject.get( \"registrationId\" ) );\n            if ( enabled && !isBlank( clientName ) && !isBlank( authorizationUri ) ) {\n              providers.add( new SsoProvider( clientName, authorizationUri, registrationId ) );\n            }\n          }\n        }\n        return providers;\n      } catch ( Exception e ) {\n        throw new IOException( \"Failed to parse SSO provider response\", e );\n      }\n    } finally {\n      if ( connection != null ) {\n        connection.disconnect();\n      }\n    }\n  }\n\n  public boolean isOAuthEnabled( String serverUrl ) throws IOException {\n    String settingsUrl = normalizeBaseUrl( serverUrl ) + \"/plugin/login/api/v0/system-settings\";\n    HttpURLConnection connection = null;\n\n    try {\n      connection = (HttpURLConnection) new URL( settingsUrl ).openConnection();\n      connection.setInstanceFollowRedirects( false );\n      connection.setRequestMethod( \"GET\" );\n      connection.setConnectTimeout( CONNECT_TIMEOUT_MS );\n      connection.setReadTimeout( READ_TIMEOUT_MS );","sourceCodeStart":57,"sourceCodeEnd":93,"githubUrl":"https://github.com/pentaho/pentaho-kettle/blob/f3058517a153da500bf4551f46d79b91bf8ec552/plugins/repositories/core/src/main/java/org/pentaho/di/ui/repo/util/SsoProviderService.java#L57-L93","documentation":"fetchProviders parses the HTTP response body as JSON (JSONArray of SSO provider entries); any exception during reading or extracting the expected fields (clientName, authorizationUri, registrationId) is wrapped in this IOException. It means the response was received but was not valid JSON or had an unexpected structure.","triggerScenarios":"Endpoint returns 2xx but body is not valid JSON, is not a JSON array, or array elements lack/mis-type the expected fields (clientName, authorizationUri, registrationId).","commonSituations":"Server returns an HTML error/login page with 200 status; a proxy injects content; server plugin version changed the response schema; truncated or empty body.","solutions":["Log/print the raw response body to see what the server actually returned","Confirm the server's login plugin version matches the expected oauth-providers response schema","Check that authentication/session cookies are valid — a login page often comes back as 200 HTML","Handle unexpected shapes defensively: check instanceof JSONArray before casting","Verify no proxy/intermediary is rewriting the response"],"exampleFix":"// before\nObject parsed = new JSONParser().parse( reader );\n// after\nObject parsed = new JSONParser().parse( reader );\nif ( !( parsed instanceof JSONArray ) ) {\n  throw new IOException( \"Unexpected SSO provider response (not a JSON array): \" + parsed );\n}","handlingStrategy":"fallback","validationCode":"// verify the endpoint speaks JSON before parsing\nconnection.setRequestProperty( \"Accept\", \"application/json\" );\nString contentType = connection.getContentType();\nif ( contentType == null || !contentType.contains( \"json\" ) ) {\n  throw new IOException( \"Expected JSON response, got: \" + contentType );\n}","typeGuard":null,"tryCatchPattern":"try {\n  providers = ssoProviderService.fetchProviders( serverUrl );\n} catch ( IOException e ) {\n  if ( e.getCause() instanceof ParseException ) {\n    log.warn( \"SSO response not parseable — server may not support SSO\" );\n  }\n  providers = Collections.emptyList();\n}","preventionTips":["Send Accept: application/json and validate the response content type before parsing","Confirm server plugin version matches the expected response schema","Log the raw body on parse failure for diagnosis","Don't assume 2xx means valid JSON — proxies can return HTML with 200"],"tags":["json","sso","parsing"],"backgroundTag":"json-parse-error","analyzedSha":"f3058517a153da500bf4551f46d79b91bf8ec552","analyzedAt":"2026-09-13T14:04:16.340Z","contentChangedAt":"2026-09-13T14:04:16.340Z","schemaVersion":2},"datasetVersion":"2026-09-20T23:17:15.980Z"}