Skip to content

ArgoClient.get_workflow_templates swallows a 404, making "list failed" indistinguishable from "no templates" #3239

@mcg1969

Description

@mcg1969

What

ArgoClient.get_workflow_templates is a generator that returns None on a 404 from the list call:

except client.rest.ApiException as e:
    ...
    if e.status == 404:
        return None

Because it's a generator, return None simply stops iteration — the value never reaches the caller and no exception is raised. list(client.get_workflow_templates()) therefore yields [], indistinguishable from a successful-but-empty list.

Why it's a problem

A 404 on list_namespaced_custom_object for workflowtemplates means the namespace or the CRD isn't present (or a misconfigured path) — not "zero templates," which is a 200 with items: []. So callers can't tell an enumeration failure from an empty cluster. For any reconciling or destructive use (e.g. tearing down templates), the failure reads silently as "nothing to do."

For contrast, within this same file: the other list-path statuses already raise (the non-Expired 410 falls through to raise ArgoClientException), and the singular getters returning None on 404 is fine — there a 404 genuinely means "that named object is absent." It's specifically the list generator where empty-on-404 loses information.

Suggested fix

Raise on the list 404, as the other statuses do, instead of return None:

if e.status == 404:
    raise ArgoClientException(error_message)

(or a typed ArgoResourceNotFound via wrap_api_error, if preferred). This keeps "no templates" as [] and surfaces a real listing failure.

Reproduced on master (linked file). Happy to send a PR if the direction looks right.

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