E07720: additional name only required for QUERY, HEADER or PATH parameters

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

What went wrong

A service parameter gives a wire name to a source that takes none. QUERY and HEADER need the name of the query parameter or header to read (':=: QUERY "q"'), and PATH may have one; REQUEST (the whole request) and CONTENT (the body) are not looked up by name, so ':=: REQUEST "body"' is this error.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 1325 (Why does EK9 reject a qualifier name on a REQUEST or C...)

How to fix it

  1. Remove the name qualifier
  2. Only QUERY and HEADER need a name (PATH may have one)

The [EXAMPLE] section below shows ':=: REQUEST "body"', and the same parameter as ':=: REQUEST' with no name.

Common causes

  • Adding qualifier to REQUEST parameter
  • Unnecessary qualifier on certain types

See also

  • E07720: unexpected name qualifier (this error)
  • E07710: missing name qualifier

Examples

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

Fails with E07720: additional name only required for QUERY, HEADER or PATH parameters

#!ek9
defines module error.e07720.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

      whole() as POST for :/
        ->
          //The whole request has no name
          request as HTTPRequest :=: REQUEST "body"
        <- response as HTTPResponse: TextResponse($request)

Fixed: Remove the name from REQUEST, CONTENT and CONTEXT

#!ek9
defines module error.e07720.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

      whole() as POST for :/
        -> request as HTTPRequest :=: REQUEST
        <- response as HTTPResponse: TextResponse($request)

Questions and answers

These Q&A entries show E07720 and its fix: