agent_patch
runs/2026-02-21__03-36-16__gpt-5-1-codex-mini/flux-pr-1230/flux-pr-1230.1-of-1.2026-03-05__17-48-26__gpt-5-1-codex-mini/agent-logs/agent.patch
20030 bytes
diff --git a/tmp/agent-patch-flux-pr-1230.1-of-1.2026-03-05__17-48-26__gpt-5-1-codex-mini/app/v2/pkg/engine/datasource/graphql_datasource/graphql_datasource.go b/app/v2/pkg/engine/datasource/graphql_datasource/graphql_datasource.go
index 97383c9..dbba18e 100644
--- a/tmp/agent-patch-flux-pr-1230.1-of-1.2026-03-05__17-48-26__gpt-5-1-codex-mini/app/v2/pkg/engine/datasource/graphql_datasource/graphql_datasource.go
+++ b/app/v2/pkg/engine/datasource/graphql_datasource/graphql_datasource.go
@@ -1459,6 +1459,10 @@ func (p *Planner[T]) printOperation() (operationBytes []byte, variablesBytes []b
return nil, nil
}
+ if !p.ensureOperationHasSelections() {
+ return nil, nil
+ }
+
if len(p.upstreamOperation.Input.Variables) > 0 {
variablesBytes = make([]byte, len(p.upstreamOperation.Input.Variables))
copy(variablesBytes, p.upstreamOperation.Input.Variables)
@@ -1502,6 +1506,26 @@ func (p *Planner[T]) printOperation() (operationBytes []byte, variablesBytes []b
return rawOperationBytes, variablesBytes
}
+func (p *Planner[T]) ensureOperationHasSelections() bool {
+ for _, node := range p.upstreamOperation.RootNodes {
+ if node.Kind != ast.NodeKindOperationDefinition {
+ continue
+ }
+
+ operation := p.upstreamOperation.OperationDefinitions[node.Ref]
+ if !operation.HasSelections || p.upstreamOperation.SelectionSetIsEmpty(operation.SelectionSet) {
+ operationName := p.upstreamOperation.OperationDefinitionNameString(node.Ref)
+ if operationName == "" {
+ operationName = "<anonymous>"
+ }
+ p.stopWithError(errors.WithStack(fmt.Errorf("printOperation: operation %q has empty selection set", operationName)))
+ return false
+ }
+ }
+
+ return true
+}
+
func (p *Planner[T]) stopWithError(err error) {
p.visitor.Walker.StopWithInternalErr(err)
}
diff --git a/tmp/agent-patch-flux-pr-1230.1-of-1.2026-03-05__17-48-26__gpt-5-1-codex-mini/app/v2/pkg/engine/plan/datasource_filter_visitor.go b/app/v2/pkg/engine/plan/datasource_filter_visitor.go
index c0a9987..1ef9286 100644
--- a/tmp/agent-patch-flux-pr-1230.1-of-1.2026-03-05__17-48-26__gpt-5-1-codex-mini/app/v2/pkg/engine/plan/datasource_filter_visitor.go
+++ b/app/v2/pkg/engine/plan/datasource_filter_visitor.go
@@ -197,10 +197,8 @@ func (f *DataSourceFilter) collectNodes(dataSources []DataSource, existingNodes
}
const (
- ReasonStage1Unique = "stage1: unique"
- ReasonStage1SameSourceParent = "stage1: same source parent of unique node"
- ReasonStage1SameSourceLeafChild = "stage1: same source leaf child of unique node"
- ReasonStage1SameSourceLeafSibling = "stage1: same source leaf sibling of unique node"
+ ReasonStage1Unique = "stage1: unique"
+ ReasonStage1SameSourceParent = "stage1: same source parent of unique node"
ReasonStage2SameSourceNodeOfSelectedParent = "stage2: node on the same source as selected parent"
ReasonStage2SameSourceNodeOfSelectedChild = "stage2: node on the same source as selected child"
@@ -218,9 +216,7 @@ const (
)
// selectUniqueNodes - selects nodes (e.g. fields) which are unique to a single datasource
-// In addition we select:
-// - parent of such node if the node is a leaf and not nested under the fragment
-// - siblings nodes
+// In addition we select parent nodes for unique chains so their root datasource stays prioritized
func (f *DataSourceFilter) selectUniqueNodes() {
for i := range f.nodes.items {
@@ -236,26 +232,8 @@ func (f *DataSourceFilter) selectUniqueNodes() {
// unique nodes always have priority
f.nodes.items[i].selectWithReason(ReasonStage1Unique, f.enableSelectionReasons)
- if !f.nodes.items[i].onFragment { // on a first stage do not select parent of nodes on fragments
- // if node parents of the unique node is on the same source, prioritize it too
- f.selectUniqNodeParentsUpToRootNode(i)
- }
-
- // if node has leaf children on the same source, prioritize them too
- children := f.nodes.childNodesOnSameSource(i)
- for _, child := range children {
- if f.nodes.isLeaf(child) && f.nodes.isNodeUnique(child) {
- f.nodes.items[child].selectWithReason(ReasonStage1SameSourceLeafChild, f.enableSelectionReasons)
- }
- }
-
- // prioritize leaf siblings of the node on the same source
- siblings := f.nodes.siblingNodesOnSameSource(i)
- for _, sibling := range siblings {
- if f.nodes.isLeaf(sibling) && f.nodes.isNodeUnique(sibling) {
- f.nodes.items[sibling].selectWithReason(ReasonStage1SameSourceLeafSibling, f.enableSelectionReasons)
- }
- }
+ // if node parents of the unique node is on the same source, prioritize them too
+ f.selectUniqNodeParentsUpToRootNode(i)
}
}
@@ -529,33 +507,6 @@ func (f *DataSourceFilter) selectDuplicateNodes(secondPass bool) {
continue
}
- // 2. Lookup for the first parent root node with enabled entity resolver
- // when we haven't found a possible duplicate
- // we need to find parent node which is a root node and has enabled entity resolver, e.g. the point in the query from where we could jump
- // it is a parent entity jump case
-
- if f.checkNodes(itemIDs,
- func(i int) bool {
- if f.nodes.items[i].IsExternal && !f.nodes.items[i].IsProvided {
- return false
- }
-
- parents := f.findPossibleParents(i)
- if len(parents) > 0 {
- if f.selectWithExternalCheck(i, ReasonStage3SelectNodeUnderFirstParentRootNode) {
- for _, parent := range parents {
- f.nodes.items[parent].selectWithReason(ReasonStage3SelectParentRootNodeWithEnabledEntityResolver, f.enableSelectionReasons)
- }
-
- return true
- }
- }
- return false
- },
- nil) {
- continue
- }
-
// stages 3,4,5 - are stages when choices are equal, and we should select first available node
// 3. we choose first available leaf node
@@ -630,6 +581,29 @@ func (f *DataSourceFilter) selectDuplicateNodes(secondPass bool) {
}) {
continue
}
+
+ // 6. Parent entity jump fallback to ensure we can resolve nodes that depend on parent roots with enabled resolvers
+ if f.checkNodes(itemIDs,
+ func(i int) bool {
+ if f.nodes.items[i].IsExternal && !f.nodes.items[i].IsProvided {
+ return false
+ }
+
+ parents := f.findPossibleParents(i)
+ if len(parents) > 0 {
+ if f.selectWithExternalCheck(i, ReasonStage3SelectNodeUnderFirstParentRootNode) {
+ for _, parent := range parents {
+ f.nodes.items[parent].selectWithReason(ReasonStage3SelectParentRootNodeWithEnabledEntityResolver, f.enableSelectionReasons)
+ }
+
+ return true
+ }
+ }
+ return false
+ },
+ nil) {
+ continue
+ }
}
}
diff --git a/tmp/agent-patch-flux-pr-1230.1-of-1.2026-03-05__17-48-26__gpt-5-1-codex-mini/app/v2/pkg/engine/plan/datasource_filter_visitor_test.go b/app/v2/pkg/engine/plan/datasource_filter_visitor_test.go
index f4ef39f..6dac729 100644
--- a/tmp/agent-patch-flux-pr-1230.1-of-1.2026-03-05__17-48-26__gpt-5-1-codex-mini/app/v2/pkg/engine/plan/datasource_filter_visitor_test.go
+++ b/app/v2/pkg/engine/plan/datasource_filter_visitor_test.go
@@ -291,7 +291,7 @@ func TestFindBestDataSourceSet(t *testing.T) {
{TypeName: "Query", FieldName: "user", DataSourceHash: 11, Path: "query.user", ParentPath: "query", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: unique"}},
{TypeName: "User", FieldName: "id", DataSourceHash: 11, Path: "query.user.id", ParentPath: "query.user", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected parent"}},
{TypeName: "User", FieldName: "name", DataSourceHash: 22, Path: "query.user.name", ParentPath: "query.user", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: unique"}},
- {TypeName: "User", FieldName: "surname", DataSourceHash: 22, Path: "query.user.surname", ParentPath: "query.user", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: same source leaf sibling of unique node"}},
+ {TypeName: "User", FieldName: "surname", DataSourceHash: 22, Path: "query.user.surname", ParentPath: "query.user", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected sibling"}},
}),
},
{
@@ -560,8 +560,8 @@ func TestFindBestDataSourceSet(t *testing.T) {
{TypeName: "Lines", FieldName: "id", DataSourceHash: 22, Path: "query.user.details.address.lines.id", ParentPath: "query.user.details.address.lines", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected parent"}},
{TypeName: "Lines", FieldName: "line1", DataSourceHash: 44, Path: "query.user.details.address.lines.line1", ParentPath: "query.user.details.address.lines", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected sibling"}},
{TypeName: "Lines", FieldName: "line2", DataSourceHash: 44, Path: "query.user.details.address.lines.line2", ParentPath: "query.user.details.address.lines", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: unique"}},
- {TypeName: "Address", FieldName: "name", DataSourceHash: 22, Path: "query.user.details.address.name", ParentPath: "query.user.details.address", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: same source leaf child of unique node"}},
- {TypeName: "Details", FieldName: "age", DataSourceHash: 22, Path: "query.user.details.age", ParentPath: "query.user.details", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage1: same source leaf child of unique node"}},
+ {TypeName: "Address", FieldName: "name", DataSourceHash: 22, Path: "query.user.details.address.name", ParentPath: "query.user.details.address", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected child"}},
+ {TypeName: "Details", FieldName: "age", DataSourceHash: 22, Path: "query.user.details.age", ParentPath: "query.user.details", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected child"}},
{TypeName: "User", FieldName: "name", DataSourceHash: 22, Path: "query.user.name", ParentPath: "query.user", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected parent"}},
}),
},
@@ -820,7 +820,7 @@ func TestFindBestDataSourceSet(t *testing.T) {
{TypeName: "Query", FieldName: "me", DataSourceHash: 11, Path: "query.me", ParentPath: "query", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: unique"}},
{TypeName: "User", FieldName: "details", DataSourceHash: 33, Path: "query.me.details", ParentPath: "query.me", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: same source parent of unique node"}},
{TypeName: "Details", FieldName: "pets", DataSourceHash: 33, Path: "query.me.details.pets", ParentPath: "query.me.details", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage1: unique"}},
- {TypeName: "Pet", FieldName: "name", DataSourceHash: 33, Path: "query.me.details.pets.name", ParentPath: "query.me.details.pets", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage1: same source leaf child of unique node"}},
+ {TypeName: "Pet", FieldName: "name", DataSourceHash: 33, Path: "query.me.details.pets.name", ParentPath: "query.me.details.pets", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected child"}},
}),
},
{
@@ -829,7 +829,7 @@ func TestFindBestDataSourceSet(t *testing.T) {
{TypeName: "Query", FieldName: "me", DataSourceHash: 11, Path: "query.me", ParentPath: "query", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: unique"}},
{TypeName: "User", FieldName: "details", DataSourceHash: 33, Path: "query.me.details", ParentPath: "query.me", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: same source parent of unique node"}},
{TypeName: "Details", FieldName: "pets", DataSourceHash: 33, Path: "query.me.details.pets", ParentPath: "query.me.details", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage1: unique"}},
- {TypeName: "Pet", FieldName: "name", DataSourceHash: 33, Path: "query.me.details.pets.name", ParentPath: "query.me.details.pets", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage1: same source leaf child of unique node"}},
+ {TypeName: "Pet", FieldName: "name", DataSourceHash: 33, Path: "query.me.details.pets.name", ParentPath: "query.me.details.pets", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected child"}},
}),
},
},
@@ -938,7 +938,7 @@ func TestFindBestDataSourceSet(t *testing.T) {
{TypeName: "NestedOne", FieldName: "uniqueOne", DataSourceHash: 11, Path: "query.user.nested.uniqueOne", ParentPath: "query.user.nested", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage1: unique"}},
{TypeName: "NestedOne", FieldName: "uniqueTwo", DataSourceHash: 22, Path: "query.user.nested.uniqueTwo", ParentPath: "query.user.nested", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage1: unique"}},
{TypeName: "User", FieldName: "object", DataSourceHash: 11, Path: "query.user.object", ParentPath: "query.user", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: unique"}},
- {TypeName: "Object", FieldName: "name", DataSourceHash: 11, Path: "query.user.object.name", ParentPath: "query.user.object", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage1: same source leaf child of unique node"}},
+ {TypeName: "Object", FieldName: "name", DataSourceHash: 11, Path: "query.user.object.name", ParentPath: "query.user.object", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected child"}},
}),
},
{
@@ -956,7 +956,7 @@ func TestFindBestDataSourceSet(t *testing.T) {
{TypeName: "NestedOne", FieldName: "uniqueOne", DataSourceHash: 11, Path: "query.user.nested.uniqueOne", ParentPath: "query.user.nested", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage1: unique"}},
{TypeName: "NestedOne", FieldName: "uniqueTwo", DataSourceHash: 22, Path: "query.user.nested.uniqueTwo", ParentPath: "query.user.nested", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage1: unique"}},
{TypeName: "User", FieldName: "object", DataSourceHash: 11, Path: "query.user.object", ParentPath: "query.user", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: unique"}},
- {TypeName: "Object", FieldName: "name", DataSourceHash: 11, Path: "query.user.object.name", ParentPath: "query.user.object", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage1: same source leaf child of unique node"}},
+ {TypeName: "Object", FieldName: "name", DataSourceHash: 11, Path: "query.user.object.name", ParentPath: "query.user.object", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected child"}},
}),
},
},
@@ -992,10 +992,10 @@ func TestFindBestDataSourceSet(t *testing.T) {
{TypeName: "PaginatedUser", FieldName: "edges", DataSourceHash: 11, Path: "query.users.edges", ParentPath: "query.users", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected parent"}},
{TypeName: "UserToEdge", FieldName: "node", DataSourceHash: 11, Path: "query.users.edges.node", ParentPath: "query.users.edges", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected parent"}},
{TypeName: "User", FieldName: "address", DataSourceHash: 22, Path: "query.users.edges.node.address", ParentPath: "query.users.edges.node", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: unique"}},
- {TypeName: "Address", FieldName: "street", DataSourceHash: 22, Path: "query.users.edges.node.address.street", ParentPath: "query.users.edges.node.address", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: same source leaf child of unique node"}},
+ {TypeName: "Address", FieldName: "street", DataSourceHash: 22, Path: "query.users.edges.node.address.street", ParentPath: "query.users.edges.node.address", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected child"}},
{TypeName: "User", FieldName: "firstName", DataSourceHash: 11, Path: "query.users.edges.node.firstName", ParentPath: "query.users.edges.node", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: unique"}},
{TypeName: "User", FieldName: "id", DataSourceHash: 11, Path: "query.users.edges.node.id", ParentPath: "query.users.edges.node", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected parent"}},
- {TypeName: "User", FieldName: "lastName", DataSourceHash: 11, Path: "query.users.edges.node.lastName", ParentPath: "query.users.edges.node", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: same source leaf sibling of unique node"}},
+ {TypeName: "User", FieldName: "lastName", DataSourceHash: 11, Path: "query.users.edges.node.lastName", ParentPath: "query.users.edges.node", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected sibling"}},
}),
},
{
@@ -1005,10 +1005,10 @@ func TestFindBestDataSourceSet(t *testing.T) {
{TypeName: "PaginatedUser", FieldName: "edges", DataSourceHash: 11, Path: "query.users.edges", ParentPath: "query.users", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected parent"}},
{TypeName: "UserToEdge", FieldName: "node", DataSourceHash: 11, Path: "query.users.edges.node", ParentPath: "query.users.edges", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected parent"}},
{TypeName: "User", FieldName: "address", DataSourceHash: 22, Path: "query.users.edges.node.address", ParentPath: "query.users.edges.node", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: unique"}},
- {TypeName: "Address", FieldName: "street", DataSourceHash: 22, Path: "query.users.edges.node.address.street", ParentPath: "query.users.edges.node.address", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: same source leaf child of unique node"}},
+ {TypeName: "Address", FieldName: "street", DataSourceHash: 22, Path: "query.users.edges.node.address.street", ParentPath: "query.users.edges.node.address", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected child"}},
{TypeName: "User", FieldName: "firstName", DataSourceHash: 11, Path: "query.users.edges.node.firstName", ParentPath: "query.users.edges.node", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: unique"}},
{TypeName: "User", FieldName: "id", DataSourceHash: 11, Path: "query.users.edges.node.id", ParentPath: "query.users.edges.node", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected parent"}},
- {TypeName: "User", FieldName: "lastName", DataSourceHash: 11, Path: "query.users.edges.node.lastName", ParentPath: "query.users.edges.node", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage1: same source leaf sibling of unique node"}},
+ {TypeName: "User", FieldName: "lastName", DataSourceHash: 11, Path: "query.users.edges.node.lastName", ParentPath: "query.users.edges.node", IsRootNode: true, Selected: true, SelectionReasons: []string{"stage2: node on the same source as selected sibling"}},
}),
},
},