11ty / 11ty-website

Documentation site for the Eleventy static site generator.

Home Page:https://www.11ty.dev/

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Github Checks / Deploys are failing due to the Twitter Token being excluded in test builds

CanIGetaPR opened this issue · comments

feed.addSource("twitterUser", "Twitter", "eleven_ty", "949639269433380864");

Trying to add the twitter feed is failing with a 401 Unauthorized response from Twitter.

https://app.netlify.com/sites/11ty/deploys/63bf868507b9cd000818558b

11:05:01 PM: [11ty] Problem writing Eleventy templates: (more in DEBUG output)
11:05:01 PM: [11ty] 1. Having trouble rendering 11ty.js template ./src/follow-feed.11ty.js (via TemplateContentRenderError)
11:05:01 PM: [11ty] 2. Bad response for https://api.twitter.com/2/users/949639269433380864/tweets?max_results=100&expansions=in_reply_to_user_id,attachments.media_keys&media.fields=width,height,alt_text,type,preview_image_url,url&tweet.fields=attachments,author_id,conversation_id,created_at,entities,id,in_reply_to_user_id,lang,public_metrics,possibly_sensitive,referenced_tweets,reply_settings,source,text,withheld (401): Unauthorized (via Error)

It's been down since Nov 15, 2022

Oh, it's because

9:23:19 AM: The following environment variables have been removed from this build to keep them secret:
9:23:19 AM: - OPENCOLLECT_API_KEY
9:23:19 AM: - TWITTER_BEARER_TOKEN

It makes sense but it means we should skip trying to load the twitter feed if it's triggered from a pull request.

Skipping processing the src/follow-feed.11ty.js file in non-privileged builds seems like the least intrusive work-around here.

A more comprehensive option would be setting some compiler flag and accessing it in the source file to determine whether or not to include twitter feeds in the build, depending if the TWITTER_BEARER_TOKEN is present. But that seems more complicated and unreliable, as it would also require a production compiler flag to ensure the twitter feed is attempted in production deployments. Introduce a complexity in a file that shouldn't be involved in building variables.