appsmithorg/appsmith · error · AppsmithPluginException

PE-PLG-5000

PE-PLG-5000

Error message

API key should not be empty. Please add an API key

What it means

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.

Source

Thrown at app/server/appsmith-plugins/googleAiPlugin/src/main/java/com/external/plugins/utils/RequestUtils.java:58

    public static String extractValueFromFormData(Map<String, Object> formData, String key) {
        return (String) formData.get(key);
    }

    public static URI createUriFromCommand(String command, String model) {
        if (GoogleAIConstants.GENERATE_CONTENT.equals(command)) {
            return URI.create(GOOGLE_AI_API_ENDPOINT + MODELS + "/" + model + GENERATE_CONTENT_ACTION);
        } else {
            throw new AppsmithPluginException(
                    AppsmithPluginError.PLUGIN_EXECUTE_ARGUMENT_ERROR, "Unsupported command: " + command);
        }
    }

    public static Mono<ResponseEntity<byte[]>> makeRequest(
            HttpMethod httpMethod, URI uri, ApiKeyAuth apiKeyAuth, BodyInserter<?, ? super ClientHttpRequest> body) {

        if (!StringUtils.hasText(apiKeyAuth.getValue())) {
            throw new AppsmithPluginException(AppsmithPluginError.PLUGIN_ERROR, GoogleAIErrorMessages.EMPTY_API_KEY);
        }

        return webClient
                .method(httpMethod)
                .uri(appendKeyInUri(apiKeyAuth.getValue(), uri))
                .contentType(MediaType.APPLICATION_JSON)
                .body(body)
                .exchangeToMono(clientResponse -> clientResponse.toEntity(byte[].class));
    }

    /**
     * Add key query params in requests
     * @param apiKey - Google AI API Key
     * @param uri - Actual request URI
     */
    private static URI appendKeyInUri(String apiKey, URI uri) {
        return UriComponentsBuilder.fromUri(uri).queryParam(KEY, apiKey).build().toUri();
    }

View on GitHub (pinned to 8cd9021c24)

Solutions

  1. Open the Google AI datasource configuration and enter a valid API key from Google AI Studio (https://aistudio.google.com/apikey).
  2. Verify the API key has no leading/trailing whitespace — paste carefully.
  3. Test the datasource connection after entering the key.
  4. If the key was revoked, generate a new one in Google AI Studio and update the datasource.
  5. Ensure environment variables or JS bindings for the API key resolve to a non-empty value.
Defensive patterns

Strategy: validation

Validate before calling

// Check API key is non-empty before executing
if (!datasources.GoogleAI.authentication.apiKey || datasources.GoogleAI.authentication.apiKey.trim() === '') {
  showAlert('Google AI API key is missing. Please configure it in the datasource.', 'error');
} else {
  await googleAiQuery.run();
}

Prevention

When it happens

Trigger: 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.

Common situations: 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.

Related errors


AI-assisted analysis of appsmithorg/appsmith@8cd9021c24 (2026-08-12). Data as JSON: /api/errors/78af83805ac10961. Report an issue: GitHub.