Skip to content

Add logging for missing mapOp in MAP_REMOVE operation #38

@coderabbitai

Description

@coderabbitai

Description

The MAP_REMOVE case in the apply method of DefaultLiveMap.MutableState silently returns when mapOp is missing, unlike the MAP_SET case which logs a warning. This creates inconsistent error handling and makes debugging more difficult.

Current Behavior

In Sources/AblyLiveObjects/Internal/DefaultLiveMap.swift around lines 458-460:

case .known(.mapRemove):
    guard let mapOp = operation.mapOp else {
        return  // Silent return
    }

Expected Behavior

Add logging before the return to match the MAP_SET case behavior:

case .known(.mapRemove):
    guard let mapOp = operation.mapOp else {
        logger.log("Could not apply MAP_REMOVE since operation.mapOp is missing", level: .warn)
        return
    }

Context

This inconsistency was identified during code review to ensure uniform error handling and easier debugging.

Backlinks:

┆Issue is synchronized with this Jira Task by Unito

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions