Skip to content

Rust resolver returns InternalError for circular segment dependencies #295

@nicklasl

Description

@nicklasl

Problem

When a circular segment dependency is detected, the Rust resolver returns an InternalError. Java returns NO_SEGMENT_MATCH, consistent with how other segment evaluation failures are handled.

Rust behavior

confidence-resolver/src/lib.rs ~L1290-1292:

if visited.contains(&segment.name) {
    fail!("circular segment dependency found");
}

The fail!() macro returns a ResolveError::Internal, which surfaces as an error to the caller.

Java behavior

AccountResolver.java ~L608-636:

if (visitedSegments.contains(segmentName)) {
    throw new InternalServerException(
        "Segment %s has a circular dependency".formatted(segmentName));
}

Java also throws, but the exception is caught in the surrounding segmentMatches() method:

} catch (RuntimeException error) {
    logger.error("Error during targeting for flag {}", flag, error);
    return false;  // returns false → NO_SEGMENT_MATCH
}

The circular dependency is logged as an error but treated as a segment evaluation failure, returning false. This causes the rule to be skipped and the flag resolves with NO_SEGMENT_MATCH.

Affected spec tests

  • circular_segment_dependency

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