<-- back to the mailing list

Gemini input validation errors

Michael Lazar lazar.michael22 at gmail.com

Fri Jan 29 03:17:18 GMT 2021

- - - - - - - - - - - - - - - - - - - 

Hi all,

Piggybacking on the recent threads about forms in gemini, how shouldwe be handling errors with input validation? I've run into thisproblem a few times already with astrobotany and I haven't found agreat solution for it yet.

REQUEST : gemini://example.com/page/inputRESPONSE : 10 Enter a choice [yes/no]REQUEST : gemini://example.com/page/input?potatoRESPONSE : ???

---

Option 1.

Return a proper error response code.

REQUEST : gemini://example.com/page/input?potatoRESPONSE : 59 Invalid choice (potato)

Pros- Feels like the semantically correct thing to do.

Cons- Many gemini clients don't display the human readable meta along the error codes (For consistency, I guess?). This results in a terribly confusing user experience.

---

Option 2.

Return a new input prompt with the error message included.

REQUEST : gemini://example.com/page/input?potatoRESPONSE : 10 Invalid choice (potato). Enter a choice [yes/no]

Pros- Convenient for the user.- The UI is reasonably clean.

Cons- It can get ugly really quickly with longer error messages being concatenated on the same line as the original prompt.

---

Option 3.

Return a successful response with the error as plain text.

REQUEST : gemini://example.com/page/input?potatoRESPONSE : 20 text/gemini Invalid option (potato).

Pros- Will always display the error message to the user.

Cons- No semantic indication that there was an error.- Can screw up browser history.

---

I know it's blasphemy but a new error code could be really nice here.Something like

54 INVALID INPUTIndicates that the query string contained a value that was notaccepted by the server. The <meta> should be a human-readableerror message that will be shown to the user. Sophisticated clientscan display the error message along with re-prompting the user withthe same input from the previous request.

Any thoughts or other ideas?

- Michael