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

Fix farcaster following constraint #628

Merged
merged 1 commit into from
Sep 18, 2024

Conversation

PooyaFekri
Copy link
Collaborator

@PooyaFekri PooyaFekri commented Sep 18, 2024

Summary by Sourcery

Fix the Farcaster following constraint by correcting the way follower status is accessed in the is_following and be_followed_by methods.

Bug Fixes:

  • Fix the issue in the Farcaster following constraint by correctly accessing the follower status using the follower's fid.

Copy link
Contributor

sourcery-ai bot commented Sep 18, 2024

Reviewer's Guide by Sourcery

This pull request fixes a bug in the Farcaster following constraint implementation. The changes modify how the follow status is retrieved and accessed in two methods: is_following and be_followed_by.

File-Level Changes

Change Details Files
Corrected the return value in the is_following and be_followed_by methods
  • Updated is_following method to access the specific FID key from the returned dictionary
  • Updated be_followed_by method to access the specific following_fid key from the returned dictionary
core/thirdpartyapp/farcaster.py

Tips
  • Trigger a new Sourcery review by commenting @sourcery-ai review on the pull request.
  • Continue your discussion with Sourcery by replying directly to review comments.
  • You can change your review settings at any time by accessing your dashboard:
    • Enable or disable the Sourcery-generated pull request summary or reviewer's guide;
    • Change the review language;
  • You can always contact us if you have any questions or feedback.

@PooyaFekri PooyaFekri merged commit f08c507 into develop Sep 18, 2024
1 check passed
Copy link
Contributor

@sourcery-ai sourcery-ai bot left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hey @PooyaFekri - I've reviewed your changes and they look great!

Here's what I looked at during the review
  • 🟡 General issues: 1 issue found
  • 🟢 Security: all looks good
  • 🟢 Testing: all looks good
  • 🟢 Complexity: all looks good
  • 🟢 Documentation: all looks good

Sourcery is free for open source - if you like our reviews please consider sharing them ✨
Help me be more useful! Please click 👍 or 👎 on each comment to tell me if it was helpful.

Comment on lines 153 to +156
"""
try:
following_fid = self._get_profile(address)["fid"]
return self._get_follow_status(fid, following_fid)
return self._get_follow_status(fid, following_fid)[following_fid]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

suggestion (bug_risk): Potential KeyError risk in dictionary access

The changes to is_following and be_followed_by methods now assume that _get_followers_status and _get_follow_status return dictionaries with specific keys. This could lead to KeyErrors if the expected keys are not present. Consider using the dict.get() method with a default value or checking for the key's existence before accessing it. Also, ensure that all code relying on these methods is updated to handle the new return type.

Suggested change
"""
try:
following_fid = self._get_profile(address)["fid"]
return self._get_follow_status(fid, following_fid)
return self._get_follow_status(fid, following_fid)[following_fid]
return self._get_followers_status(follower_fid, fid).get(fid, False)
except (
RequestException,
IndexError,
"""
try:
following_fid = self._get_profile(address)["fid"]
return self._get_follow_status(fid, following_fid).get(following_fid, False)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant