Skip to content

Bug: Script crashes when reaching last page of dependencies (next_url is None) #1

@dmchaledev

Description

@dmchaledev

Description

The script crashes with a TypeError when it reaches the last page of dependencies because next_url becomes None but the code tries to access next_url['href'] without checking.

Steps to Reproduce

  1. Run the script against an organization with few dependencies
  2. The script iterates through pages until there is no "next" link
  3. On the last page, soup.select_one("a[href*=after]") returns None
  4. Code tries to access next_url['href'] on None, causing crash

Expected Behavior

The script should gracefully exit the loop when there are no more pages, or handle the None case appropriately.

Actual Behavior

TypeError: 'NoneType' object is not subscriptable

Code Location

next_url = soup.select_one("a[href*=after]")
# Missing check: if next_url is None: break
print(next_url['href'])
return next_url['href']

Suggested Fix

next_url = soup.select_one("a[href*=after]")
if next_url is None:
    return None  # Signal end of pagination
return next_url['href']

And update the main loop:

while iterations > 1:
    result = get_dependencies_for_url(current_url, cookies)
    if result is None:
        break
    current_url = result
    iterations -= 1

This would also eliminate the need for the hardcoded iterations = 313 value.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions