Skip to content
Luna
Esc
↑↓navigate↵open⌘Jpreview
On this page

Invalid

The request does not match what the luna type declares, so Luna refused it before any handler ran.

Invalid means the request itself is wrong, and Luna refused it before your handler ran. The status is 400, or 405 for a wrong method and 413 for a body that is too large.

Issue

A call fails at once, and the message names what is wrong. A List takes one key field, so this call with two key segments fails.

curl -X POST "$LUNA_URL/List/groceries/extra/add" -H "luna-key: $LUNA_KEY"
{"error": {"code": "Invalid", "message": "List takes 1 key segment(s), got 2"}}

Cause

Luna checks each call against the luna type before anything wakes:

Status What was wrong
400 The body is not JSON, or not a JSON object of arguments
400 An argument is missing, extra or of the wrong type
400 The URL has the wrong number of key segments, or a key value of the wrong type
400 A file upload’s content type differs from the one its URL was signed for
405 A handler was called with a method other than POST, or a route with a method it does not take
413 A route’s body, or an upload, is over its size limit

A call from another luna fails with Invalid when the handler it names does not exist.

Invalid differs from NotFound. NotFound means the luna type, handler or route does not exist for this caller. Invalid means it exists but the request does not fit it.

Solution

Do not retry. The same request fails the same way.

  • Compare the arguments with the handler’s args. TypeScript apps get them typed from the luna type.
  • Encode each key field as its own path segment, in the order the luna type declares them.
  • For a 413, send a smaller body. Limits lists the sizes.

Was this page helpful?