Skip to content

Conversation

@N-Yashwitha
Copy link

Description

This PR fixes a KeyError in gcp/social_card_tags.py that occurred when a post did not have a filename key. Previously, the script crashed if at least one post was missing this field.

The change ensures that posts without filename are safely skipped, preventing the social card tagging process from failing. This resolves issue #2727

Changes

Modified the dictionary comprehension in gcp/social_card_tags.py:

post_by_slug = {
post["filename"].split(".")[0]: post
for post in posts
if "filename" in post
}
Only posts with a filename key are now processed.
No other functionality was modified.

Screenshots

Screenshot from 2025-10-26 19-55-32

Previously, running python gcp/social_card_tags.py raised KeyError: 'filename'.
After this fix, the script runs successfully without crashing.

Tests

Tested locally in Python virtual environment:
Activated venv: source venv/bin/activate
Installed dependencies: pip install beautifulsoup4 requests pyyaml
Ran script: python gcp/social_card_tags.py
Verified that posts missing filename are skipped.
Verified that posts with valid filename are processed correctly.

@vercel
Copy link

vercel bot commented Oct 26, 2025

@N-Yashwitha is attempting to deploy a commit to the PolicyEngine Team on Vercel.

A member of the Team first needs to authorize it.

@anth-volk
Copy link
Collaborator

Thanks for these changes @N-Yashwitha. That said, this repo is no longer in active development, and the social card tagging has been supplanted.

@anth-volk anth-volk closed this Nov 25, 2025
@github-project-automation github-project-automation bot moved this from Todo to Closed in policyengine-app Nov 25, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

Status: Closed

Development

Successfully merging this pull request may close these issues.

2 participants