Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Not all articles have a pillarName #4

Open
OpenBagTwo opened this issue Sep 12, 2024 · 0 comments
Open

Not all articles have a pillarName #4

OpenBagTwo opened this issue Sep 12, 2024 · 0 comments
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested

Comments

@OpenBagTwo
Copy link
Owner

Had two runs over the past few weeks fail with the traceback:

Traceback (most recent call last):
  File "/home/runner/work/MarketWatch/MarketWatch/post_generator.py", line 297, in <module>
    generate_post(os.environ["GUARDIAN_API_KEY"], date)
  File "/home/runner/work/MarketWatch/MarketWatch/post_generator.py", line 265, in generate_post
    article = get_random_article(guardian_api_key, date)
              ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "/home/runner/work/MarketWatch/MarketWatch/post_generator.py", line 196, in get_random_article
    "tags": [article["pillarName"]],
             ~~~~~~~^^^^^^^^^^^^^^
KeyError: 'pillarName'

The obvious solution would be to replace

"tags": [article["pillarName"]],

with:

    "tags" :  [article["pillarName"]] if "pillarName" in article else [],

but the concern is that if this field is ever legitimately renamed, then no articles will have tags from then on.

I suggest looking into which articles don't have pillarNames—it's quite possible that they're not something I want to be pulling in the first place (in which case get_random_article should be rerun).

@OpenBagTwo OpenBagTwo added bug Something isn't working help wanted Extra attention is needed good first issue Good for newcomers question Further information is requested labels Sep 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working good first issue Good for newcomers help wanted Extra attention is needed question Further information is requested
Projects
None yet
Development

No branches or pull requests

1 participant