Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Empty string cannot be passed in HttpTrigger query string

Aperta
#683 0 commenti 0 reazioni 1 assegnatario Vedi su GitHub

@kamperiadis ci sta già lavorando.

Dal 6/1/2023.

  • #694 di @kamperiadis — aperta

Valutazione

Questa issue non è ancora stata valutata.

Descrizione

area:java-functions Break Change Enhancement needs-discussion New Feature reviewed
Repro steps
  1. Run the following function from templates:
package com.function;

import java.util.*;
import com.microsoft.azure.functions.annotation.*;
import com.microsoft.azure.functions.*;

/**
 * Azure Functions with HTTP Trigger.
 */
public class HttpTriggerJava1 {
    /**
     * This function listens at endpoint "/api/HttpTriggerJava1". Two ways to invoke it using "curl" command in bash:
     * 1. curl -d "HTTP Body" {your host}/api/HttpTriggerJava1
     * 2. curl {your host}/api/HttpTriggerJava1?name=HTTP%20Query
     */
    @FunctionName("HttpTriggerJava1")
    public HttpResponseMessage run(
            @HttpTrigger(name = "req", methods = {HttpMethod.GET, HttpMethod.POST}, authLevel = AuthorizationLevel.FUNCTION) HttpRequestMessage<Optional<String>> request,
            final ExecutionContext context) {
        context.getLogger().info("Java HTTP trigger processed a request.");

        // Parse query parameter
        String query = request.getQueryParameters().get("name");
        String name = request.getBody().orElse(query);

        if (name == null) {
            return request.createResponseBuilder(HttpStatus.BAD_REQUEST).body("Please pass a name on the query string or in the request body").build();
        } else {
            return request.createResponseBuilder(HttpStatus.OK).body("Hello, " + name).build();
        }
    }
}
  1. Send the following request: http://localhost:7071/api/HttpTriggerJava1?name=
Expected behavior

name should be set to an empty string and the function should return "Hello, "

Actual behavior

name is set to null and the function returns "Please pass a name on the query string or in the request body"

Known workarounds

None

Related information

Similar issue in PowerShell worker: https://github.com/Azure/azure-functions-powershell-worker/issues/895

Lingua principale
Java
Stelle
103
Fork
74
Merge medio
1g 11h
PR unite (30g)
3

Preparare l'ambiente

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di Azure/azure-functions-java-worker

Tutte le issue di Azure/azure-functions-java-worker

Issue simili

Altre issue su Java

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.