﻿# Flyte 2 map results: exception objects need explicit handling before metric aggregation

Handle Flyte 2 mapped task failures as explicit result states, preserving input order, candidate identities and evaluation coverage when collecting metrics.

Author: Retrivium editorial team
Updated: 2026-11-04
Canonical URL: https://retrivium.ai/journal/fg2-flyte-two-map-exception-results-evaluation-coverage/
Language: en

## Collection finishes without every shard succeeding

A mapped model evaluator scores several document shards. The collector reaches the end of its iterator, but one item is an exception rather than a score dictionary. Treating iterator completion as full evaluation coverage can produce an incomplete metric or a later type error far from the original failure.

Define the result contract before aggregation. The collector needs to distinguish a valid low score, an empty but valid shard and a failed action. These observations should remain identifiable in the final report.

## Read the map error contract

The [Flyte 2 mapping guide](https://www.union.ai/docs/v2/flyte/user-guide/tasks/task-programming/map/) documents return_exceptions and explains how failures surface in the result stream. It also states that results are yielded in input order. Neither behavior removes the need to inspect the result associated with each input.

Choose deliberately between collecting per-item failures and stopping through raised failure. A collection-friendly policy is useful only when the downstream code can represent partial outcomes without silently converting them to successful observations.

## Preserve identity through aggregation

The [task guide](https://www.union.ai/docs/v2/flyte/user-guide/get-started/core-concepts/tasks/) describes typed task inputs and outputs. Carry a shard identity in successful records, and associate failures with the corresponding requested input. Do not discard the input association when filtering exceptions out of a list.

[Distributed shard overlap](/journal/data-guide-distributed-shard-worker-overlap/) explains why coverage requires more than an aggregate count. A report can contain the expected number of rows yet include a repeated shard or omit a difficult population after a failed action.

## Parallel execution is a separate dimension

The [fanout guide](https://www.union.ai/docs/v2/flyte/user-guide/tasks/task-programming/fanout/) distinguishes distributing task actions from ordinary local coroutine work. Limiting simultaneous work does not reduce the number of requested logical items or turn their errors into valid results.

For the evaluation, preserve attempted examples and completed examples separately. If a mean uses only completed shards, state that population and consider differing shard sizes. A mean over shard means is not automatically the same statistic as a mean over all examples.

## Make partial completion visible

Use a controlled failing input to exercise the collector and verify its report. Confirm that it retains the failing shard identity, does not substitute an arbitrary score and declares the resulting evaluation coverage.

Compare this with [success denominator selection](/journal/provider-stream-success-sli-denominator/). Operational continuation can be useful, but the final metric must still explain which observations contributed and which requested observations are missing.
