8000 [Bug]: BinaryOperatorAggregate ignores types.Overwrite, fails on empty-channel Overwrite, and mutates state on duplicate Overwrite · Issue #22702 · infiniflow/ragflow · GitHub
[go: up one dir, main page]

Skip to content

[Bug]: BinaryOperatorAggregate ignores types.Overwrite, fails on empty-channel Overwrite, and mutates state on duplicate Overwrite #22702

Open

Description

@adityajai119

Self Checks

  • I have searched for existing issues, including closed ones.
  • I confirm that I am using English to submit this report.
  • Non-english title submitions will be closed directly.
  • Please do not modify this template :) and fill in all the required fields.

RAGFlow workspace code commit ID

da4a155

RAGFlow image version

N/A (local source checkout of main at da4a155)

Other environment information

  • OS: Windows 11 (amd64)
  • Go: 1.27.3 (CGO_ENABLED=0)

Actual behavior

BinaryOperatorAggregate in internal/harness/graph/channels/binop.go has three related bugs when handling Overwrite values:

  1. isOverwrite ignores types.Overwrite / *types.Overwrite: isOverwrite checks for an internal interface{ GetValue() interface{} } and a single-key map[string]interface{}{"__overwrite__": v}. However, types.Overwrite in internal/harness/graph/types/types.go stores the value in the exported Value field and does not implement GetValue(), so types.NewOverwrite(v) and types.Overwrite{Value: v} are never recognized as overwrite wrappers and are passed straight to c.operator as regular values.
  2. Empty-channel Update bypasses overwrite handling on values[0]: When IsMissing(c.value) is true (for example NewBinaryOperatorAggregate(nil, op)), Update executes c.value = values[0]; values = values[1:] before checking isOverwrite. As a result, a leading Overwrite stores the raw wrapper object in c.value, leaves seenOverwrite false (so a second Overwrite in the same super-step succeeds instead of returning InvalidUpdateError), and passes the raw wrapper into c.operator for any remaining values.
  3. Duplicate Overwrite mutates c.value before failing: On a super-step containing multiple Overwrite values (or a normal value followed by two Overwrite values), Update writes earlier values into c.value before encountering the second Overwrite and returning InvalidUpdateError, leaving the channel state mutated on a rejected update.
  4. Expected behavior

    • isOverwrite should unwrap *types.Overwrite (when non-nil) and types.Overwrite alongside the existing overwriter interface and constants.Overwrite map form.
    • BinaryOperatorAggregate.Update should validate and resolve Overwrite entries across the entire values slice before mutating c.value:
      • Two or more Overwrite values in the same super-step return InvalidUpdateError and leave c.value unchanged (including keeping an empty channel empty).
      • A single Overwrite sets c.value to the unwrapped value regardless of whether the channel was initially Missing or whether other normal values appear in the same super-step.

    Steps to reproduce

    1. Create ch := channels.NewBinaryOperatorAggregate(int(0), channels.IntAdd), seed 10, then call ch.Update([]interface{}{types.NewOverwrite(99)}): ch.Get() returns 10 instead of 99.
    2. Create ch := channels.NewBinaryOperatorAggregate(nil, channels.IntAdd) and call ch.Update([]interface{}{map[string]interface{}{constants.Overwrite: 42}}): ch.Get() returns the raw map map["__overwrite__":42] instead of 42.
    3. Create ch := channels.NewBinaryOperatorAggregate(int(0), channels.IntAdd), seed 10, and call ch.Update([]interface{}{map[string]interface{}{constants.Overwrite: 42}, map[string]interface{}{constants.Overwrite: 99}}): Update returns InvalidUpdateError, yet ch.Get() is mutated to 42 instead of remaining 10.

    Additional information

    A fix with regression tests is ready.

    AI-assisted: drafted with an AI coding agent; the tests above were run locally.

Activity

  1. added a commit that references this issue on Nov 24, 2026
    9469f3d
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

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

      0