E07793: Web Service parameter type cannot be HTTPContext

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

What went wrong

You're using HTTPContext type but not with CONTEXT access type. HTTPContext can only be used with :=: CONTEXT, not with QUERY, PATH, HEADER, or CONTENT.

Worked examples

Compilable examples demonstrating this error and the correct fix:

  • ek9 -q 1331 (Why can't I bind HTTPContext to a QUERY parameter in a...)

How to fix it

  1. Use :=: CONTEXT for HTTPContext parameters
  2. Or use appropriate type for the access type

The [EXAMPLE] section below shows an HTTPContext read from a query value, then the context taken with ':=: CONTEXT' and the query read as a String.

Common causes

  • HTTPContext with wrong access type (:=: QUERY, :=: PATH)
  • Confusion about access type requirements

See also

  • E07793: HTTPContext with wrong access type (this error)
  • E07791: Similar - wrong type for CONTEXT
  • E07790: Similar - HTTPRequest with wrong access type

Examples

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

Fails with E07793: Web Service parameter type cannot be HTTPContext

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

      info() as GET for :/info
        ->
          //A query value is text, never the context
          context as HTTPContext :=: QUERY "q"
        <- response as HTTPResponse: TextResponse($context)

Fixed: Use HTTPContext only with CONTEXT

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

      info() as GET for :/info
        -> context as HTTPContext :=: CONTEXT
        <- response as HTTPResponse: TextResponse($context)

      search() as GET for :/search
        -> term as String :=: QUERY "q"
        <- response as HTTPResponse: TextResponse(term)

Questions and answers

These Q&A entries show E07793 and its fix:

Found a problem?

If EK9 reported E07793 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.