PokeAPI/ditto

Netlify is returning an object describing the site instead of our API result

sargunv opened this issue ยท 8 comments

I don't understand this Netlify bug(?) at all.

Test call: /api/v2/pokemon/

Response from my sandbox site: https://pastebin.com/raw/ZqyHfBT7
Response from the pokeapi site: https://pastebin.com/raw/LSxzc5Sb

Both sites are running identical code. What's up with that?

@neverendingqs you seem familiar with Netlify, you got any idea? I'd like to have more info to report to Netlify than just "this is broken sometimes".

Further investigation: the redirect/proxy works fine, but the function call doesn't work. Here I try calling the function directly:

EDIT: I changed the name, these links are now broken. The first link's result was the correct resource list slice, while the second result was identical to the second pastebin above.

Here it is working fine in the sandbox: https://sargunv-sandbox.netlify.com/.netlify/functions/resource-list/?endpoint=pokemon&offset=436&limit=5

And here's the same broken call to the prod instance: https://pokeapi.netlify.com/.netlify/functions/resource-list/?endpoint=pokemon&offset=436&limit=

I checked the function log, it's totally empty for the prod instance, so our function isn't even getting invoked there.

  • Hypothesis: it's an account config issue
    • Moved the sandbox to the org
    • No change; sandbox works, prod doesn't
  • Hypothesis: it's a site config issue
    • Checked all configs, matched all settings except branch and name
    • git diff lambda..master is empty; no branch differences
    • No change
  • Hypothesis: branch issue somehow even though they're identical
    • Swapped branches
    • No change
  • Hypothesis: name issue somehow???
    • Swapped names (with a third name in between)
    • The third name confirmed swap is instant
    • The badness followed the pokeapi.netlify.com name to the other site instance

Changed the name to "pokeapi-prod" and it's all good. Looks like the problem only happens when the name is "pokeapi" so I guess it only happens when site name == org name?

Hypothesis: it's sending the request to the Netlify API instead of our content since our paths start with /api/, returning the weird JSON object describing our site.

I'll replicate it with a minimal example on my own account and report the bug to Netlify soon.

Good replication work. Sounds like a dodgy bug! But maybe it's intended too :(

But maybe it's intended too :(

If I'm right about how this issue works, it won't be a problem when we apply the real domain ๐Ÿ‘

I only skimmed the issue because it sounds like you arrived at a MCV, but I can take a deeper look if you want me to. Maybe <team name>.netlify.com is always reserved for something else (but that's kinda wierd too...).

See the investigation branch: https://github.com/PokeAPI/ditto/tree/investigation

Launched it under the pokeapi account under site name pokeapi. Launched it under the sargunv account under the site name sargunv.

https://pokeapi.netlify.com/.netlify/functions/foo/
https://sargunv.netlify.com/.netlify/functions/foo/

One gives the bad object, the other calls the function properly. Both are named after the account. So site name == account name isn't the trigger.

I've reported what I know here to Netlify. What concerns me is the mystery JSON contains some kind of "secret".

Netlify has now fixed the bug as far as I can tell. Closing the issue.