Seattleite 412 Scheme



  • Status:

    Message: The remote server returned an error: (412) Precondition Failed.
    Status: ProtocolError

    ... huh?

    The destination server is running the not-at-all-completely-shitty WebAPI, which of course has "preconditions" which "fail", but wouldn't bother telling the developer WHICH precondition failed, or WHY it failed, because that might make it possible to troubleshoot and we can't have that.

    I'm going to drive over to Microsoft, and guy the guy on the ASP.Net team or the WebAPI team (whichever serves up that error) and strangle them until they realize TELLING ME PRECONDITION FAILED WITHOUT TELLING ME WHICH PRECONDITION FAILED OR WHY IT FAILED IS FUCKING USELESS YOU PIECE OF SHIT I HATE THIS HATE THIS



  • That's only supposed to be used for things like "If-Match" headers. I assume you aren't sending an If-Match header because that would be silly.


  • Discourse touched me in a no-no place

    The .net web ecosystem is built upon opaque bullshit errors. See: Fucking WCF and its fucking faulting fucking channels.



  • I know. And I'm not.

    That's why I'm stumped. The only "official" statement I can see is that it means your headers are wrong, but which one? And wrong how?

    @Weng said:

    The .net web ecosystem is built upon opaque bullshit errors. See: Fucking WCF and its fucking faulting fucking channels.

    Seriously!

    I get shit from my boss if I send a vague error message which MIGHT waste ONE of our developers time three years from now.

    That guy working at Microsoft has written a vague error message that has wasted THOUSANDS of programmer's time for DECADES. He should be fucking FLOGGED.

    There ain't no justice.



  • A lot of Go libraries wrap all their error handling in something that panics with the error when it happened and then recovers before it goes back to user code. But runtime errors are also errors, and they get panic called on them because there's no way to return an error value from a pointer dereference. So occasionally when debugging something I'll get "runtime error: nil pointer dereference" as an error message from a function.

    The solution is to define your own type and then wrap the error in that before you throw it. Something like this:

    type weFuckedUp struct {
        error
    }
    
    // ...
    
    defer func() {
        if r := recover(); r != nil {
            err = r.(weFuckedUp).error
        }
    }()
    
    // ...
    
    if err != nil {
        panic(weFuckedUp{err})
    }
    

    Demonstration: http://play.golang.org/p/5ohckjl04U



  • @ben_lubar said:

    A lot of Go libraries wrap all their error handling in something that panics with the error when it happened and then recovers before it goes back to user code.

    Unity does something like this, too, and it's a massive pain. My debug console is full of partial exception messages with no stack trace, but Unity internally wraps everything in Try-Catch blocks so attaching the Visual Studio debugger and trying to break on an exception to find out what's actually wrong is rather fruitless.


  • Discourse touched me in a no-no place

    @blakeyrat said:

    That's why I'm stumped. The only "official" statement I can see is that it means your headers are wrong, but which one? And wrong how?

    If you (and your HTTP library) weren't sending a conditional action, it's actually pretty easy to solve what's going on: the service is returning the wrong error (and without any details either). The programmer of the service you're talking to is a mouth-breathing moron who needs his pituitary gouging out with a rusty spork.

    I'm sure it would be possible to sugar-coat things more, but I've just been thinking about local politics and that always puts me in a very sour mood.



  • It turns out 412 means:

    "Hey you're sending JSON I can't serialize into the object expected, also JSON keys are case-sensitive you stupid motherfucker."


  • Discourse touched me in a no-no place

    @blakeyrat said:

    It turns out 412 means:

    "Hey you're sending JSON I can't serialize into the object expected, also JSON keys are case-sensitive you stupid motherfucker."

    Only in that nincompoop's head. It should be a 400 (miscellaneous “you done wrong”) with some descriptive text in the body saying what was wrong.



  • @dkf said:

    It should be a 400 (miscellaneous “you done wrong”) with some descriptive text in the body saying what was wrong.

    502 OK.



  • @dkf said:

    Only in that nincompoop's head. It should be a 400 (miscellaneous “you done wrong”) with some descriptive text in the body saying what was wrong.

    I retested and I'm still getting 412, so that wasn't the solution.

    I'm completely stumped. I can't even find a list of things that could possibly result in 412 errors.


  • Discourse touched me in a no-no place

    @blakeyrat said:

    I can't even find a list of things that could possibly result in 412 errors.

    If you're doing it right, it's a fairly short list.

    I'm guessing that it's not that and that you're stuck with a moronic nitwit who doesn't know jack shit about how a REST service ought to work. Which is only like 99% of all REST service creators… :cry:



  • The moronic nitwit is WebAPI, or perhaps IIS.

    I don't even know what particular piece of software is serving the error. Much less what the error means or how to solve it.

    I've made my request an exact duplicate of an existing request, no luck.


  • Impossible Mission Players - A

    @blakeyrat said:

    exact duplicate of an existing request,

    So then it's the site that is failing? Does the original working request work correctly at present?
    You'd think that it would be a 500 then, but maybe not...


  • Discourse touched me in a no-no place

    @blakeyrat said:

    The moronic nitwit is WebAPI, or perhaps IIS.

    Probably not. It's probably the author of the code that's running inside that environment, and who has decided that using 412 as an error code is a good idea instead of using some sensible and quite possibly correct default…

    I've only seen this sort of thing a squillion times before (writing a system to do arbitrary web service orchestration lets you see some really dumb shit put up by people that Bert Glanstrom would have field day with) and the containing framework really isn't at fault. They have to support custom error codes (because some things just can't be figured out before they hit the service impl) and some people can't see a tool without using it wrongly.



  • @Tsaukpaetra said:

    So then it's the site that is failing? Does the original working request work correctly at present?

    The original request is application/x-www-form-urlencoded, mine is application/json. That's literally the only difference. The content sent matches the Content-Type. (i.e. it's actually valid JSON.)

    There's nothing on the web server or IIS config that would disable JSON for this controller, nor does anybody working here remember ever adding or configuring anything like that.

    I'm using a WebClient. I tried both WebClient.UploadData and manually converting the JSON string to UTF8, no good. I also tried WebClient.UploadString, no good.

    412 Precondition Failed is supposed to me I'm giving the web server contradictory instructions-- for example, my Content-Type says it's JSON but the actual data is an image upload. I'm not doing that.

    To make things even MORE annoying, I can't get this damned request to show up in Fiddler, so I can't guarantee it's not wrong. Because I can't see what .net's actually fucking sending. Because .net has a moronic retard feature that says it won't bother using your proxy if you're sending to localhost, which makes no fucking sense.


  • Impossible Mission Players - A

    @blakeyrat said:

    sending to localhost

    Does it behave if you HOSTS a bogus name to localhost?



  • @dkf said:

    you're stuck with a moronic nitwit who doesn't know jack shit about how a REST service ought to work. Which is only like 99% of all REST service creators…

    And 99% of people posting to ShackOpium


  • Discourse touched me in a no-no place

    @blakeyrat said:

    412 Precondition Failed is supposed to me I'm giving the web server contradictory instructions-- for example, my Content-Type says it's JSON but the actual data is an image upload.

    It's actually meant to be used for “I'm doing an update, but only if these conditions still hold” where the conditions are basically ways to abort if something changed behind your back. When the stuff in the body is bad, that should just be a 400 (since HTTP doesn't really say very much more specialised about it). Unless it makes the service really choke, when it should be 500 instead. :smile:


  • Discourse touched me in a no-no place

    @Lorne_Kates said:

    ShackOpium

    Is that the new name for Facebook?



  • It turns out, and this never even occurred to me, some previous developer had MANUALLY ADDED 412s to our codebase.

    I didn't notice because for reasons I won't get into right now I couldn't debug on my local machine, I had to use one of the lab servers. When it occurred to me that maybe the error wasn't coming from IIS or WebAPI, I found it right away.

    What a fucker.


  • Discourse touched me in a no-no place

    @blakeyrat said:

    It turns out, and this never even occurred to me, some previous developer had MANUALLY ADDED 412s to our codebase.

    Hah! Nailed it.
    @blakeyrat said:
    What a fucker.

    Yep. I did recommend a rusty spork with good reason.


  • Impossible Mission Players - A

    @blakeyrat said:

    When it occurred to me that maybe the error wasn't coming from IIS or WebAPI, I found it right away.

    I decided it was better practice to stop manually throwing InternalServerErrors, since it broke the stack or something when trying to debug them. Made code a bit better I think?

    Status: Joined the "I want to be in the spotlight" club. Hooray for being a sheeple?



  • @blakeyrat said:

    and guy the guy on the ASP.Net team

    ...how, exactly, does one guy someone?


  • Discourse touched me in a no-no place

    @rc4 said:

    how, exactly, does one guy someone?

    By being @accalia's alt is the most likely explanation.


  • kills Dumbledore

    @rc4 said:

    how, exactly, does one guy someone?

    Ge's talking about Guy, the guy on the ASP.Net team. Guy's a great guy


Log in to reply
 

Looks like your connection to What the Daily WTF? was lost, please wait while we try to reconnect.