Skip to content

Lists API getAll([...], true) Invalid value 'OR' for 'filter_branch_type', must be one of 'ASSOCIATION' #478

@stvsimons

Description

@stvsimons

I'm encountering a consistent issue with the lists()->listsApi()->(getAll | getById | getByName) methods when passing the Include Filters argument as true.

PHP Fatal error:  Uncaught InvalidArgumentException: Invalid value 'OR' for 'filter_branch_type', must be one of 'ASSOCIATION' in /path-to/vendor/hubspot/api-client/codegen/Crm/Lists/Model/PublicPropertyAssociationFilterBranchFilterBranchesInner.php:438
Stack trace:
#0 /path-to/vendor/hubspot/api-client/codegen/Crm/Lists/ObjectSerializer.php(541): HubSpot\Client\Crm\Lists\Model\PublicPropertyAssociationFilterBranchFilterBranchesInner->setFilterBranchType('OR')
#1 /path-to/vendor/hubspot/api-client/codegen/Crm/Lists/ObjectSerializer.php(541): HubSpot\Client\Crm\Lists\ObjectSerializer::deserialize(Object(stdClass), '\\HubSpot\\Client...', NULL)
#2 /path-to/vendor/hubspot/api-client/codegen/Crm/Lists/ObjectSerializer.php(419): HubSpot\Client\Crm\Lists\ObjectSerializer::deserialize(Object(stdClass), '\\HubSpot\\Client...', NULL)
#3 /path-to/vendor/hubspot/api-client/codegen/Crm/Lists/ObjectSerializer.php(541): HubSpot\Client\Crm\Lists\ObjectSerializer::deserialize(Array, '\\HubSpot\\Client...', NULL)
#4 /path-to/vendor/hubspot/api-client/codegen/Crm/Lists/Api/ListsApi.php(934): HubSpot\Client\Crm\Lists\ObjectSerializer::deserialize(Object(stdClass), '\\HubSpot\\Client...', Array)
#5 /path-to/vendor/hubspot/api-client/codegen/Crm/Lists/Api/ListsApi.php(854): HubSpot\Client\Crm\Lists\Api\ListsApi->getAllWithHttpInfo(Array, true, 'application/jso...')
#6 /path-to/test-listapi-getall.php(12): HubSpot\Client\Crm\Lists\Api\ListsApi->getAll(Array, true)
#7 {main}
  thrown in /path-to/vendor/hubspot/api-client/codegen/Crm/Lists/Model/PublicPropertyAssociationFilterBranchFilterBranchesInner.php on line 438

Steps to duplicate the issue:

  1. Setup a HubSpot sandbox account with a sample of Contacts and at least one Dynamic or Snapshot Contact Lists with a simple filter 'firstname' starts with 'S'.
  2. Use composer and install hubspot/api-client
composer.json
{
    "require": {
        "hubspot/api-client": "^12.1"
    }
}
  1. Create test file using copy of PHP code from https://developers.hubspot.com/docs/reference/api/crm/lists#get-%2Fcrm%2Fv3%2Flists%2F.
  2. Manually insert the List ID in the get*() call (sample here is list id '25'), and insert the appropriate Private APP or OAuth access token for the sandbox:
<?php
// test-listapi-getall.php
require 'vendor/autoload.php';

use HubSpot\Factory;
use HubSpot\Client\Crm\Lists\ApiException;

$client = Factory::createWithAccessToken('pat-###-####-####-###-####');

try {
    $apiResponse = $client->crm()->lists()->listsApi()->getAll(['25'], true);
    var_dump($apiResponse);
} catch (ApiException $e) {
    echo "Exception when calling lists_api->get_all: ", $e->getMessage();
}
  1. Run test file:
% php test-listapi-getall.php
PHP Fatal error:  Uncaught InvalidArgumentException: Invalid value 'OR' for 'filter_branch_type', must be one of 'ASSOCIATION' in /path-to/vendor/hubspot/api-client/codegen/Crm/Lists/Model/PublicPropertyAssociationFilterBranchFilterBranchesInner.php:438

Here I used listApi()->getAll(), the same exception is thrown in getById() and getByName() when the list being retrieved is Dynamic or Snapshot with a simple filter property comparison AND the Include Filters argument is passed as TRUE. Setting the 2nd call argument (Include Filter) to FALSE no exception is thrown.

The developer.hubspot.com page's "Test call" function with the same arguments works, but I'm guessing the Response block content is from whichever language backend the site used and not necessarily the PHP sample code shown in the Request block.

Development page example 'Test call' Response using the same arguments in sample code above, as does using curl with the same getall arguments:

% curl --request GET \
  --url 'https://api.hubapi.com/crm/v3/lists/?listIds=25&includeFilters=true' \
  --header 'authorization: Bearer pat-###-#######-###-#####'
{
  "lists": [
    {
      "listId": "25",
      "listVersion": 2,
      "createdAt": "2025-04-21T22:47:18.074Z",
      "updatedAt": "2025-04-22T15:15:34.720Z",
      "filtersUpdatedAt": "2025-04-22T15:15:34.720Z",
      "processingStatus": "COMPLETE",
      "createdById": "5709857",
      "updatedById": "5709857",
      "processingType": "DYNAMIC",
      "objectTypeId": "0-1",
      "name": "Unnamed list 4/21/2025 6:46:15 PM",
      "filterBranch": {
        "filterBranches": [
          {
            "filterBranches": [],
            "filters": [
              {
                "property": "firstname",
                "operation": {
                  "operator": "STARTS_WITH",
                  "includeObjectsWithNoValueSet": false,
                  "values": [
                    "S"
                  ],
                  "operationType": "MULTISTRING"
                },
                "filterType": "PROPERTY"
              }
            ],
            "filterBranchOperator": "AND",
            "filterBranchType": "AND"
          }
        ],
        "filters": [],
        "filterBranchOperator": "OR",
        "filterBranchType": "OR"
      },
      "size": 3,
      "listPermissions": {
        "teamsWithEditAccess": [],
        "usersWithEditAccess": []
      },
      "membershipSettings": {
        "membershipTeamId": null,
        "includeUnassigned": null
      }
    }
  ]
}

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions