E07710: additional name needed for QUERY, HEADER or PATH parameters

Category: E07xxx Full resolution · Reported in phase: EXPLICIT_TYPE_SYMBOL_DEFINITION · Classification: SERVICE_HTTP_PARAM_NEEDS_QUALIFIER · All error codes

What went wrong

A QUERY or HEADER service parameter has no wire name. The compiler needs the name of the query parameter or header to read, written as a String after the source: ':=: QUERY "q"', ':=: HEADER "Authorization"'. PATH does not need one: 'id as String :=: PATH' reads the '{id}' segment of the URI template, matched by the parameter's own name (a name may still be given, ':=: PATH "id"'). The compiler message lists PATH as well, but an unnamed PATH parameter compiles.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 1324 (Why does a QUERY or HEADER service parameter need a name...)

How to fix it

  1. Add the wire name as a String after QUERY or HEADER
  2. The variable name and the wire name may differ: 'term :=: QUERY "q"'

The [EXAMPLE] section below shows a HEADER parameter with no name, and the same one reading the "User-Agent" header.

Common causes

  • Assuming the variable name is used as the query or header name
  • Writing QUERY/HEADER like PATH, which needs no name

See also

  • E07710: missing name qualifier (this error)
  • E07720: a name qualifier on a source that takes none (REQUEST, CONTENT)

Examples

Every example is compiled by the EK9 compiler: the first fails exactly as captioned, the others fix it.

Fails with E07710: additional name needed for QUERY, HEADER or PATH parameters

#!ek9
defines module error.e07710.bad

  defines class

    TextResponse with trait of HTTPResponse
      text as String?

      default private TextResponse()

      TextResponse()
        -> body as String
        this.text: body

      override contentType() as pure
        <- rtn as String: "text/plain"

      override content()
        <- rtn as Bytes: Bytes().withUtf8(text)

      override status() as pure
        <- rtn as Integer: 200

      default operator ?

  defines service

    Addresses for :/addresses open

      byAgent() as GET for :/agent
        ->
          //Which header?
          agent as String :=: HEADER
        <- response as HTTPResponse: TextResponse(agent)

Fixed: Name the header, query or path value

#!ek9
defines module error.e07710.good

  defines class

    TextResponse with trait of HTTPResponse
      text as String?

      default private TextResponse()

      TextResponse()
        -> body as String
        this.text: body

      override contentType() as pure
        <- rtn as String: "text/plain"

      override content()
        <- rtn as Bytes: Bytes().withUtf8(text)

      override status() as pure
        <- rtn as Integer: 200

      default operator ?

  defines service

    Addresses for :/addresses open

      byAgent() as GET for :/agent
        -> agent as String :=: HEADER "User-Agent"
        <- response as HTTPResponse: TextResponse(agent)

Questions and answers

These Q&A entries show E07710 and its fix:

Found a problem?

If EK9 reported E07710 for a program you think is valid, or did not report it where it should have, use the compiler form with the smallest program that shows it. If this page is wrong or unclear, use the documentation form. Both are at github.com/ek9lang/ek9-issues.