{"record":{"id":"78af83805ac10961","repo":"appsmithorg/appsmith","slug":"pe-plg-5000-78af83","errorCode":"PE-PLG-5000","errorMessage":"API key should not be empty. Please add an API key","messagePattern":"API key should not be empty\\. Please add an API key","errorType":"exception","errorClass":"AppsmithPluginException","httpStatus":500,"severity":"error","filePath":"app/server/appsmith-plugins/googleAiPlugin/src/main/java/com/external/plugins/utils/RequestUtils.java","lineNumber":58,"sourceCode":"\n    public static String extractValueFromFormData(Map<String, Object> formData, String key) {\n        return (String) formData.get(key);\n    }\n\n    public static URI createUriFromCommand(String command, String model) {\n        if (GoogleAIConstants.GENERATE_CONTENT.equals(command)) {\n            return URI.create(GOOGLE_AI_API_ENDPOINT + MODELS + \"/\" + model + GENERATE_CONTENT_ACTION);\n        } else {\n            throw new AppsmithPluginException(\n                    AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, \"Unsupported command: \" + command);\n        }\n    }\n\n    public static Mono<ResponseEntity<byte[]>> makeRequest(\n            HttpMethod httpMethod, URI uri, ApiKeyAuth apiKeyAuth, BodyInserter<?, ? super ClientHttpRequest> body) {\n\n        if (!StringUtils.hasText(apiKeyAuth.getValue())) {\n            throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, GoogleAIErrorMessages.EMPTY_API_KEY);\n        }\n\n        return webClient\n                .method(httpMethod)\n                .uri(appendKeyInUri(apiKeyAuth.getValue(), uri))\n                .contentType(MediaType.APPLICATION_JSON)\n                .body(body)\n                .exchangeToMono(clientResponse -> clientResponse.toEntity(byte[].class));\n    }\n\n    /**\n     * Add key query params in requests\n     * @param apiKey - Google AI API Key\n     * @param uri - Actual request URI\n     */\n    private static URI appendKeyInUri(String apiKey, URI uri) {\n        return UriComponentsBuilder.fromUri(uri).queryParam(KEY, apiKey).build().toUri();\n    }","sourceCodeStart":40,"sourceCodeEnd":76,"githubUrl":"https://github.com/appsmithorg/appsmith/blob/8cd9021c24cdbea1c3c12c966073708e83db60c2/app/server/appsmith-plugins/googleAiPlugin/src/main/java/com/external/plugins/utils/RequestUtils.java#L40-L76","documentation":"RequestUtils.makeRequest (RequestUtils.java:54-59) throws this when the API key from the datasource's ApiKeyAuth has no text content, checked via StringUtils.hasText(apiKeyAuth.getValue()). The API key is required to append the key query parameter to the request URI (line 63). This error uses PLUGIN_ERROR (PE-PLG-5000) rather than PLUGIN_EXECUTE_ARGUMENT_ERROR, reflecting that it's a datasource-level configuration issue rather than a per-query argument problem.","triggerScenarios":"The Google AI datasource's authentication is configured with an ApiKeyAuth whose value is null, empty, or whitespace-only. When makeRequest is called to send the HTTP request to the Google AI API, the key check fails before the WebClient call is made.","commonSituations":"1) Datasource was created but the API key field was left empty. 2) API key was entered but contains only whitespace or was pasted incorrectly. 3) API key was revoked or deleted from Google AI Studio but the datasource still references the old (now empty) value. 4) Environment variable or JS binding for the API key evaluates to empty at runtime.","solutions":["Open the Google AI datasource configuration and enter a valid API key from Google AI Studio (https://aistudio.google.com/apikey).","Verify the API key has no leading/trailing whitespace — paste carefully.","Test the datasource connection after entering the key.","If the key was revoked, generate a new one in Google AI Studio and update the datasource.","Ensure environment variables or JS bindings for the API key resolve to a non-empty value."],"exampleFix":null,"handlingStrategy":"validation","validationCode":"// Check API key is non-empty before executing\nif (!datasources.GoogleAI.authentication.apiKey || datasources.GoogleAI.authentication.apiKey.trim() === '') {\n  showAlert('Google AI API key is missing. Please configure it in the datasource.', 'error');\n} else {\n  await googleAiQuery.run();\n}","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Enter a valid API key from Google AI Studio in the datasource configuration.","Test the datasource connection after entering the key.","If the key was revoked, generate a new one and update the datasource promptly.","Avoid whitespace in the API key field."],"tags":["google-ai","gemini","api-key","authentication","datasource","appsmith"],"backgroundTag":null,"analyzedSha":"8cd9021c24cdbea1c3c12c966073708e83db60c2","analyzedAt":"2026-08-12T22:14:19.293Z","schemaVersion":2},"datasetVersion":"2026-08-12T23:17:12.415Z"}