# Mean silent fail in file upload forms

**URL:** <https://discourse.elm-lang.org/t/mean-silent-fail-in-file-upload-forms/3693>\
**Category:** Request Feedback\
**Created:** [May 24, 2019, 1:45pm UTC](https://discourse.elm-lang.org/t/mean-silent-fail-in-file-upload-forms/3693 "2019-05-24T13:45:56Z")\
**Posts on this page:** 6\
**Page:** 1

<div class="post-metadata">

**Author:** ![MrMovl](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/mrmovl/32/303_2.png) [@MrMovl](https://discourse.elm-lang.org/u/MrMovl)\
**Post date:** [May 24, 2019, 1:45pm UTC](https://discourse.elm-lang.org/t/mean-silent-fail-in-file-upload-forms/3693/1 "2019-05-24T13:45:57Z")

</div>

Hi there,

I thought about posting this as an issue for the elm/file package, but I am not sure if it is right there. So I’ll just write this here and hope you have some feedback for me and/or this issue.

We just debugged a silly mistake which was really hard to find, because the [on “change”](https://package.elm-lang.org/packages/elm/html/latest/Html-Events#on) function fails silently when you mess up your Decoder. I made a small example (stolen from the [docs](https://elm-lang.org/blog/working-with-files)):

This works:  
[https://ellie-app.com/5CZ3rKQrFYYa1](https://ellie-app.com/5CZ3rKQrFYYa1)

This doesn’t:  
[https://ellie-app.com/5CZ3XVgjRSfa1](https://ellie-app.com/5CZ3XVgjRSfa1)

The first tries to decode the `files` field as a list, the second one as a single file element. In the broken version the Msg is just not triggered. Our somewhat new elm dev was pretty frustrated with this behaviour. What do you think, is this something that could/should be fixed? Could we make elm not just silently swallow the error? Or write it in the docs? The mean thing is, the docs for on say:

> When an event occurs, the decoder tries to turn the event object into an Elm value. If successful, the value is routed to your `update` function.

But no mention of the error case.

Thanks for your input!

---

<div class="post-metadata">

**Author:** ![pdamoc](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/pdamoc/32/36_2.png) [@pdamoc](https://discourse.elm-lang.org/u/pdamoc)\
**Post date:** [May 24, 2019, 6:39pm UTC](https://discourse.elm-lang.org/t/mean-silent-fail-in-file-upload-forms/3693/2 "2019-05-24T18:39:38Z")

</div>

> [@MrMovl](#):
>
> Could we make elm not just silently swallow the error?

If you want to debug the decoder you could make it return a `Result String a` instead of just `a`

Here is your failing example with a decorator for the decoder:  
[https://ellie-app.com/5D65w9GCyQqa1](https://ellie-app.com/5D65w9GCyQqa1)

---

<div class="post-metadata">

**Author:** ![MrMovl](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/mrmovl/32/303_2.png) [@MrMovl](https://discourse.elm-lang.org/u/MrMovl)\
**Post date:** [May 27, 2019, 7:09am UTC](https://discourse.elm-lang.org/t/mean-silent-fail-in-file-upload-forms/3693/3 "2019-05-27T07:09:00Z")

</div>

Thanks, that sounds like an awesome _best practice_ for json decoders. I am probably spoiled because I’ve always controllen the API I was working with when writing elm frontend code, but out there in the wild you should probably always do that.

With that pratice in mind it seems less important for that error to get more vocal, but I still think that it is bad that this particular error is just silent. I would expect a huge warning sign in the docs at least. Is it me, or do others think so too?

---

<div class="post-metadata">

**Author:** ![pdamoc](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/pdamoc/32/36_2.png) [@pdamoc](https://discourse.elm-lang.org/u/pdamoc)\
**Post date:** [May 27, 2019, 7:36am UTC](https://discourse.elm-lang.org/t/mean-silent-fail-in-file-upload-forms/3693/4 "2019-05-27T07:36:53Z")

</div>

> [@MrMovl](#):
>
> Thanks, that sounds like an awesome _best practice_ for json decoders. I am probably spoiled because I’ve always controllen the API I was working with when writing elm frontend code, but out there in the wild you should probably always do that.

Json decoder failures are always present when dealing with http calls. (It will produce a `BadBody` error) The silent failure is only when dealing with decoding events. That silent failure is actually a feature because it allows one to not generate messages on certain event conditions.

---

<div class="post-metadata">

**Author:** ![dta](https://yyz1.discourse-cdn.com/flex035/user_avatar/discourse.elm-lang.org/dta/32/1917_2.png) [@dta](https://discourse.elm-lang.org/u/dta)\
**Post date:** [May 28, 2019, 12:56am UTC](https://discourse.elm-lang.org/t/mean-silent-fail-in-file-upload-forms/3693/5 "2019-05-28T00:56:06Z")

</div>

It is a very, very small “feature” since adding a no-op message is trivial. I think compiler-enforced error checking is worth this small inconvenience in the same way it is for http requests.

---

<div class="post-metadata">

**Author:** ![system](https://canada1.discourse-cdn.com/flex035/uploads/elm_lang/original/1X/50a05e53677a2c3b47776d7abd0f113eb50193a1.png) [@system](https://discourse.elm-lang.org/u/system)\
**Post date:** [June 7, 2019, 1:01am UTC](https://discourse.elm-lang.org/t/mean-silent-fail-in-file-upload-forms/3693/6 "2019-06-07T01:01:12Z")

</div>

This topic was automatically closed 10 days after the last reply. New replies are no longer allowed.
