backend icon indicating copy to clipboard operation
backend copied to clipboard

Saving blank answer leads to 400 error

Open heyzec opened this issue 6 months ago • 3 comments

To reproduce

  1. Go to a mission
  2. Delete every line of code, leaving not even a newline
  3. Press save

An error 400 Bad Request will be sent from backend.

heyzec avatar Jun 25 '25 18:06 heyzec

It appears that this is an issue with how the backend is designed, specifically in assessments.ex where the relevant error is returned here.

On further debugging it seems that a blank answer is not allowed by the backend:

errors: [answer: {"invalid answer provided for answer type.\nChangeset: #Ecto.Changeset<action: nil, changes: %{}, errors: [code: {\"can't be blank\", [validation: :required]}], data: #Cadet.Assessments.AnswerTypes.ProgrammingAnswer<>, valid?: false>", []}], data: #Cadet.Assessments.Answer<>, valid?: false>

I do believe that we should allow blank submissions (as you can just get around this by typing a newline/space), but let's hear what @RichDom2185 has to say about this.

sayomaki avatar Jun 25 '25 19:06 sayomaki

but let's hear what @RichDom2185 has to say about this.

Agreed, thanks!

RichDom2185 avatar Jun 26 '25 13:06 RichDom2185

Will be moving this issue to backend.

sayomaki avatar Jun 26 '25 13:06 sayomaki