Skip to content

Handle 207 multi-status responses in bulk operations #4

Description

@lineoffligbot

Bulk operations on /adsApi/v1 do not return 200. They return 207, and the
body carries per-item outcomes:

{
  "success":        [ ... ],
  "partialSuccess": [ ... ],
  "error":          [ ... ]
}

:raise_error only fires at status >= 400, so a create_campaign call where 300
of 1000 campaigns failed returns a perfectly healthy HTTP::Response. Nothing in
the client signals that anything went wrong. The caller has to know to inspect
three arrays, and nothing in the generated signature tells them so.

Declared responses for POST /adsApi/v1/create/campaigns:

207 CreateCampaign 207 response
400 BadRequest
401 Unauthorized
403 Forbidden
404 NotFound
413 ContentTooLarge
429 TooManyRequests
500 502 503 504

Options

  1. Leave HTTP::Response as the return value and document the 207 shape. Cheapest,
    keeps the client thin, but the footgun stays.
  2. Return a small result object for multi-status operations exposing
    #success, #partial_success, #errors, and a #success? predicate.
  3. Raise when error is non-empty. Probably wrong: partial success is a legitimate
    outcome the API is deliberately modelling, not an exception.

Leaning toward 2, with the generator emitting it only for operations that declare
a 207.

Out of scope

Auto-chunking bulk arrays. The limits are maxItems: 1000, minItems: 1, and
exceeding them returns a documented 413 with CONTENT_TOO_LARGE
("The request is too large. Consider splitting it into multiple requests."),
so oversized requests fail loudly rather than silently truncating. At 1000 items
per call, chunking is a nicety rather than a correctness issue.

Metadata

Metadata

Assignees

No one assigned

    Labels

    enhancementNew feature or request

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions