agent_patch
runs/2026-02-28__13-38-10__gpt-5-1-codex-mini/flux-pr-1230/flux-pr-1230.1-of-1.2026-02-28__13-38-10__gpt-5-1-codex-mini/agent-logs/agent.patch
20219 bytes
diff --git a/tmp/agent-patch-flux-pr-1230.1-of-1.2026-02-28__13-38-10__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..30f41e6 100644
--- a/tmp/agent-patch-flux-pr-1230.1-of-1.2026-02-28__13-38-10__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
@@ -1470,6 +1470,11 @@ func (p *Planner[T]) printOperation() (operationBytes []byte, variablesBytes []b
return nil, nil
}
+ if err := ensureOperationHasSelections(p.upstreamOperation); err != nil {
+ p.stopWithError(errors.WithStack(fmt.Errorf("printOperation: %w", err)))
+ return nil, nil
+ }
+
p.generateQueryPlansForFetchConfiguration(p.upstreamOperation)
p.debugPrintQueryPlan(p.upstreamOperation)
@@ -1502,6 +1507,51 @@ func (p *Planner[T]) printOperation() (operationBytes []byte, variablesBytes []b
return rawOperationBytes, variablesBytes
}
+func ensureOperationHasSelections(operation *ast.Document) error {
+ for _, node := range operation.RootNodes {
+ if node.Kind != ast.NodeKindOperationDefinition {
+ continue
+ }
+
+ definition := operation.OperationDefinitions[node.Ref]
+ label := operationDefinitionLabel(operation, node.Ref)
+
+ if !definition.HasSelections {
+ return fmt.Errorf("operation %s has no selections", label)
+ }
+
+ selectionSetRef := definition.SelectionSet
+ if selectionSetRef < 0 || selectionSetRef >= len(operation.SelectionSets) {
+ return fmt.Errorf("operation %s has an invalid selection set", label)
+ }
+
+ if len(operation.SelectionSets[selectionSetRef].SelectionRefs) == 0 {
+ return fmt.Errorf("operation %s has an empty selection set", label)
+ }
+ }
+
+ return nil
+}
+
+func operationDefinitionLabel(operation *ast.Document, ref int) string {
+ if name := operation.OperationDefinitionNameString(ref); name != "" {
+ return name
+ }
+
+ definition := operation.OperationDefinitions[ref]
+
+ switch definition.OperationType {
+ case ast.OperationTypeQuery:
+ return "query"
+ case ast.OperationTypeMutation:
+ return "mutation"
+ case ast.OperationTypeSubscription:
+ return "subscription"
+ default:
+ return fmt.Sprintf("operation definition #%d", ref)
+ }
+}
+
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-02-28__13-38-10__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..1e69c7c 100644
--- a/tmp/agent-patch-flux-pr-1230.1-of-1.2026-02-28__13-38-10__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"
@@ -219,8 +217,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
+// - parent of such node, even when it is nested under a fragment
func (f *DataSourceFilter) selectUniqueNodes() {
for i := range f.nodes.items {
@@ -236,26 +233,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 it too
+ f.selectUniqNodeParentsUpToRootNode(i)
}
}
@@ -529,33 +508,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 +582,29 @@ func (f *DataSourceFilter) selectDuplicateNodes(secondPass bool) {
}) {
continue
}
+
+ // 6. Lookup for the first parent root node with enabled entity resolver (fallback)
+ 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-02-28__13-38-10__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..acf02a9 100644
--- a/tmp/agent-patch-flux-pr-1230.1-of-1.2026-02-28__13-38-10__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{"stage1: unique"}},
}),
},
{
@@ -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{"stage1: unique"}},
+ {TypeName: "Details", FieldName: "age", DataSourceHash: 22, Path: "query.user.details.age", ParentPath: "query.user.details", IsRootNode: false, Selected: true, SelectionReasons: []string{"stage1: unique"}},
{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{"stage1: unique"}},
}),
},
{
@@ -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{"stage1: unique"}},
}),
},
},
@@ -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{"stage1: unique"}},
}),
},
{
@@ -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{"stage1: unique"}},
}),
},
},
@@ -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{"stage1: unique"}},
{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{"stage1: unique"}},
}),
},
{
@@ -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{"stage1: unique"}},
{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{"stage1: unique"}},
}),
},
},