26

A bit ago, at about 2019-11-13 15:09 UTC, the SE API started randomly responding with site is required errors.

I've see it in the following situations:

  • There are lots of these reported by SmokeDetector, which reports such errors into Charcoal HQ.

    Note: I've added code to SmokeDetector such that SD won't report these errors into the chat rooms (having so many error reports was disruptive). Not reporting into the chat rooms doesn't mean the errors aren't still happening. The plan is to revert that change once the error in the SE API is resolved. If helpful for testing the API, we can revert the change and start posting the reports again.

  • I've seen this as a response when making a request on the SE API page, which showed a response of:

    {
      "error_id": 400,
      "error_message": "site is required",
      "error_name": "bad_parameter"
    }
    

    The URL which produced that should respond with:

    {
        "items":[],
        "has_more":false,
        "quota_max":300,
        "quota_remaining":296
    }
    

    It does respond with that, most of the time, but will infrequently respond with the "site is required" error.

    When attempting to make the above call from the SE API Documentation page, the response I received was:

    enter image description here

  • I've also seen this at least once in a userscript within the last 30 minutes.

This error is quite intermittent. Most requests complete correctly. We're seeing it a lot on SmokeDetector, because SmokeDetector makes a lot of requests. If you're going to test this, you'll probably need to make the request a few/several/many times prior to seeing this, but if things were working properly, you wouldn't see it at all.

Now getting CORS errors, which are more widespread

The SE API is now giving CORS errors in many circumstances.

Cross-Origin Request Blocked: The Same Origin Policy disallows reading the remote resource at https://api.stackexchange.com/2.2/posts/58842606?site=stackoverflow&_=1573665872964. (Reason: CORS header ‘Access-Control-Allow-Origin’ missing).

The above URL won't give a CORS error from this page. To duplicate, try the following from the JavaScript console on a page on SO Chat.:

$.get("https://api.stackexchange.com/2.2/posts/58842606?site=stackoverflow")
4
  • 4
    I'm seeing consistent issues with CORS
    – TylerH
    Commented Nov 13, 2019 at 17:31
  • 1
    Yep. Those just started up a few minutes ago.
    – Makyen Mod
    Commented Nov 13, 2019 at 17:32
  • 2
    I bet it's related to the rep recalculation
    – Machavity Mod
    Commented Nov 13, 2019 at 19:33
  • It's now giving CORS errors from both SO and Meta SO too, at least for me Commented Nov 13, 2019 at 23:04

1 Answer 1

18

Thanks for reporting. We're working on porting our websites to ASP.NET Core, and those errors you've seen were a result of this.

We caught the first error ourselves on a canary build and fixed it since it surfaced in the logs before deploying a full build. That full build contained the 2nd bug (no CORS headers), which we didn't see in our logs, but fixed quickly after seeing a bug report on MSE.

This bug was introduced to the ASP.NET MVC (old framework) code when we were porting (cross-targeting) the common API code to ASP.NET Core. As a twist of fate, the new (ASP.NET Core) code actually is unit-tested and checks verifies the presence of the CORS headers. But, unfortunately, it doesn't power api.stackexchange.com yet (which still runs on ASP.NET Core), only our mobile app's API backend.

3
  • 1
    Great! Thanks for fixing it. It sounds like, for the future, it's more effective to report on MSE. I'm happy to do so. Is that the better choice?
    – Makyen Mod
    Commented Nov 15, 2019 at 0:02
  • 2
    Yeah, probably, the API is a network-wide thing, and the api tag there has more activity.
    – m0sa
    Commented Nov 15, 2019 at 0:23
  • 2
    Then I will report issues with the API there. Thanks. :-)
    – Makyen Mod
    Commented Nov 15, 2019 at 1:20

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .