fix(gh_trending): scrape github.com/trending for real trending data - #1
Merged
Conversation
The handler queried the GitHub Search API for recently-created repos
sorted by all-time stars, which is not actual trending data and never
matched github.com/trending. It also emitted a nested schema
({generated_at, weekly:{period,repos}}) that did not match what the
Astro site reads, and referenced an undefined HEADERS in the README
fetch (NameError, silently swallowed).
- Scrape https://github.com/trending?since=weekly|monthly (public HTML,
no token required) via BeautifulSoup; parse name/url/description/
language/stars/stars_this_period per Box-row article.
- Emit the flat schema the site expects: {updated_at, weekly[], monthly[]}
with stars_this_period, fixing the broken "+N this week" badges.
- README enrichment is now best-effort: works unauthenticated, returns
"" on failure so summaries still build from name/description/language.
- Fix email_digest reading the old nested weekly shape (AttributeError
on the new flat data — the Friday digest's trending section was broken).
- Add beautifulsoup4 dependency and parser unit tests with a fixture.
Cron schedule (weekly Mon 07:00 UTC) and infra are unchanged.The preview.yml build-check ran `cdk synth`, which failed at route53.HostedZone.fromLookup with StackAccountRegionNotSpecified: the stack account came from CDK_DEFAULT_ACCOUNT, which is unset in CI (no AWS creds), so the lookup key could not be formed. - Fall back to the known deployment account (333674319299) when CDK_DEFAULT_ACCOUNT is absent, so synth has an account/region. - Commit cdk.context.json (un-ignore it) so the hosted-zone lookup is served from cache and synth needs no live AWS call. This is the CDK-recommended practice for reproducible synth. Unblocks the PR build-check. Deploy (deploy.yml) is unaffected — it already provides real credentials via OIDC.
Uh oh!
There was an error while loading. Please reload this page.
datj9 added a commit
that referenced
this pull request
Jul 11, 2026
* fix(gh_trending): scrape github.com/trending for real trending data
The handler queried the GitHub Search API for recently-created repos
sorted by all-time stars, which is not actual trending data and never
matched github.com/trending. It also emitted a nested schema
({generated_at, weekly:{period,repos}}) that did not match what the
Astro site reads, and referenced an undefined HEADERS in the README
fetch (NameError, silently swallowed).
- Scrape https://github.com/trending?since=weekly|monthly (public HTML,
no token required) via BeautifulSoup; parse name/url/description/
language/stars/stars_this_period per Box-row article.
- Emit the flat schema the site expects: {updated_at, weekly[], monthly[]}
with stars_this_period, fixing the broken "+N this week" badges.
- README enrichment is now best-effort: works unauthenticated, returns
"" on failure so summaries still build from name/description/language.
- Fix email_digest reading the old nested weekly shape (AttributeError
on the new flat data — the Friday digest's trending section was broken).
- Add beautifulsoup4 dependency and parser unit tests with a fixture.
Cron schedule (weekly Mon 07:00 UTC) and infra are unchanged.
* fix(infra): make cdk synth work in CI without AWS credentials
The preview.yml build-check ran `cdk synth`, which failed at
route53.HostedZone.fromLookup with StackAccountRegionNotSpecified:
the stack account came from CDK_DEFAULT_ACCOUNT, which is unset in CI
(no AWS creds), so the lookup key could not be formed.
- Fall back to the known deployment account (333674319299) when
CDK_DEFAULT_ACCOUNT is absent, so synth has an account/region.
- Commit cdk.context.json (un-ignore it) so the hosted-zone lookup is
served from cache and synth needs no live AWS call. This is the
CDK-recommended practice for reproducible synth.
Unblocks the PR build-check. Deploy (deploy.yml) is unaffected — it
already provides real credentials via OIDC.
---------
Co-authored-by: Dat <dat.nguyen@ringkas.co.id>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for freeto join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
The `gh_trending` Lambda never read github.com/trending. It queried the GitHub Search API for repos created in the last 7/30 days, sorted by all-time stars — a fundamentally different list from github.com/trending (which ranks by stars gained in a window). This is why the trending data on the live site looked wrong.
Two latent bugs rode along:
Change
Cron schedule (weekly Mon 07:00 UTC) and all infra are unchanged. CDK bundling installs the new dependency automatically from `requirements.txt`.
Test plan
Out of scope
The site has been stale since 2026-05-12 because SSM `/tech-bytes/github-token` is still `PLACEHOLDER`, so the auto-rebuild trigger no-ops. That's a separate ops fix (set a real PAT) and does not block this correctness fix.