@@ -24,6 +24,16 @@ def _clamp_max_pipes_per_org(value: int) -> int:
2424 return max (SEARCH_PIPES_MAX_PER_ORG_MIN , min (SEARCH_PIPES_MAX_PER_ORG_CAP , value ))
2525
2626
27+ def _coerce_org_pipes_count (raw : object ) -> int | None :
28+ """Parse GraphQL ``Organization.pipesCount`` for truncation checks."""
29+ if raw is None :
30+ return None
31+ try :
32+ return int (raw )
33+ except (TypeError , ValueError ):
34+ return None
35+
36+
2737class PipeService (BasePipefyClient ):
2838 """Service for Pipe-related operations."""
2939
@@ -112,6 +122,11 @@ async def search_pipes(
112122 If pipe_name is provided, only pipes matching the name are included,
113123 sorted by match score (best matches first).
114124 May include ``search_limits`` describing caps applied.
125+
126+ When ``pipe_name`` is omitted, per-org ``pipes_truncated`` and
127+ ``search_limits.pipes_truncated`` are True if the client sliced the list
128+ to ``max_pipes_per_org`` **or** the API returned fewer ``pipes`` than
129+ ``pipesCount`` (user-visible subset vs org total).
115130 """
116131 stripped = pipe_name .strip () if pipe_name else None
117132 name_search = stripped if stripped else None
@@ -132,17 +147,22 @@ async def search_pipes(
132147 organizations : list [dict ] = []
133148 for org in raw_orgs :
134149 pipes = list (org .get ("pipes" ) or [])
135- truncated = len (pipes ) > per_org_cap
136- if truncated :
150+ pipes_count = _coerce_org_pipes_count (org .get ("pipesCount" ))
151+ truncated = len (pipes ) > per_org_cap or (
152+ pipes_count is not None and len (pipes ) < pipes_count
153+ )
154+ if len (pipes ) > per_org_cap :
137155 pipes = pipes [:per_org_cap ]
138- limits ["pipes_truncated" ] = True
139156 row : dict = {
140157 "id" : org .get ("id" ),
141158 "name" : org .get ("name" ),
142159 "pipes" : pipes ,
143160 }
161+ if pipes_count is not None :
162+ row ["pipesCount" ] = pipes_count
144163 if truncated :
145164 row ["pipes_truncated" ] = True
165+ limits ["pipes_truncated" ] = True
146166 organizations .append (row )
147167 return {"organizations" : organizations , "search_limits" : limits }
148168
0 commit comments