Skip to content

[Bug] [Integration] [ArgoCD] 'NoneType' object is not iterable during resync when a registered cluster has no applications #2967

@teroahonen-vungle

Description

@teroahonen-vungle

Ocean Framework Version

0.38.20

Integration Version

0.2.26 (ghcr.io/port-labs/port-ocean-argocd:latest)

Steps to reproduce

  1. Register two or more clusters in ArgoCD
  2. Deploy applications to only some clusters — leave at least one cluster with zero applications
  3. Trigger a resync of the ArgoCD integration

What did you expect to see?

Resync completes successfully. Clusters with no applications are treated as returning an empty list and skipped gracefully.

What did you see instead?

Resync fails with 'NoneType' object is not iterable. No entities are synced to Port and the
integration logs "Resync failed with N errors, skipping delete phase due to incomplete state".

The ArgoCD API returns {"items": null} (not {"items": []}) for clusters with no applications.
get_paginated_resources uses response_data.get("items", []) which only falls back to the default
when the key is absent — when the key is present with a null value it returns None, and
batched(None, PAGE_SIZE) raises TypeError.

The fix is a one-character change on client.py line 108:

# broken
for batch in batched(response_data.get("items", []), PAGE_SIZE):

# fixed — handles both absent key and explicit null
for batch in batched(response_data.get("items") or [], PAGE_SIZE):

This pattern is already used correctly in get_resources (line 85):
return response_data["items"] or []

Full traceback:
File "/app/client.py", line 108, in get_paginated_resources
for batch in batched(response_data.get("items", []), PAGE_SIZE):
Exception: 'NoneType' object is not iterable

Are you willing to submit a PR?

  • I'm willing to submit a PR!

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't workingintegrationA change in integration files

    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