agent_patch
runs/2026-02-21__03-36-16__gpt-5-1-codex-mini/flux-pr-1209/flux-pr-1209.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/agent-logs/agent.patch
7555 bytes
diff --git a/tmp/agent-patch-flux-pr-1209.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/v2/pkg/engine/datasource/grpc_datasource/compiler.go b/app/v2/pkg/engine/datasource/grpc_datasource/compiler.go
index 1b519b7..a203f10 100644
--- a/tmp/agent-patch-flux-pr-1209.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/v2/pkg/engine/datasource/grpc_datasource/compiler.go
+++ b/app/v2/pkg/engine/datasource/grpc_datasource/compiler.go
@@ -322,8 +322,18 @@ func (p *RPCCompiler) Compile(executionPlan *RPCExecutionPlan, inputData gjson.R
invocations := make([]Invocation, 0, len(executionPlan.Calls))
for _, call := range executionPlan.Calls {
- inputMessage := p.doc.MessageByName(call.Request.Name)
- outputMessage := p.doc.MessageByName(call.Response.Name)
+ inputRef := p.doc.MessageRefByName(call.Request.Name)
+ if inputRef == -1 {
+ return nil, fmt.Errorf("request message %s for method %s not found in proto schema", call.Request.Name, call.MethodName)
+ }
+
+ outputRef := p.doc.MessageRefByName(call.Response.Name)
+ if outputRef == -1 {
+ return nil, fmt.Errorf("response message %s for method %s not found in proto schema", call.Response.Name, call.MethodName)
+ }
+
+ inputMessage := p.doc.Messages[inputRef]
+ outputMessage := p.doc.Messages[outputRef]
request := p.buildProtoMessage(inputMessage, &call.Request, inputData)
response := p.newEmptyMessage(outputMessage)
diff --git a/tmp/agent-patch-flux-pr-1209.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/v2/pkg/engine/datasource/grpc_datasource/compiler_test.go b/app/v2/pkg/engine/datasource/grpc_datasource/compiler_test.go
index 5e098c3..88c7620 100644
--- a/tmp/agent-patch-flux-pr-1209.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/v2/pkg/engine/datasource/grpc_datasource/compiler_test.go
+++ b/app/v2/pkg/engine/datasource/grpc_datasource/compiler_test.go
@@ -291,3 +291,47 @@ func TestBuildProtoMessage(t *testing.T) {
require.Equal(t, 1, len(invocations))
}
+
+func TestCompileMissingRequestMessage(t *testing.T) {
+ compiler, err := NewProtoCompiler(grpctest.MustProtoSchema(t), nil)
+ require.NoError(t, err)
+
+ executionPlan := &RPCExecutionPlan{
+ Calls: []RPCCall{
+ {
+ MethodName: "QueryUser",
+ Request: RPCMessage{
+ Name: "NonExistingRequest",
+ },
+ Response: RPCMessage{
+ Name: "QueryUserResponse",
+ },
+ },
+ },
+ }
+
+ _, err = compiler.Compile(executionPlan, gjson.ParseBytes([]byte(`{"variables":{}}`)))
+ require.ErrorContains(t, err, "request message NonExistingRequest for method QueryUser not found in proto schema")
+}
+
+func TestCompileMissingResponseMessage(t *testing.T) {
+ compiler, err := NewProtoCompiler(grpctest.MustProtoSchema(t), nil)
+ require.NoError(t, err)
+
+ executionPlan := &RPCExecutionPlan{
+ Calls: []RPCCall{
+ {
+ MethodName: "QueryUser",
+ Request: RPCMessage{
+ Name: "QueryUserRequest",
+ },
+ Response: RPCMessage{
+ Name: "NonExistingResponse",
+ },
+ },
+ },
+ }
+
+ _, err = compiler.Compile(executionPlan, gjson.ParseBytes([]byte(`{"variables":{}}`)))
+ require.ErrorContains(t, err, "response message NonExistingResponse for method QueryUser not found in proto schema")
+}
diff --git a/tmp/agent-patch-flux-pr-1209.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/v2/pkg/engine/datasource/grpc_datasource/execution_plan_visitor.go b/app/v2/pkg/engine/datasource/grpc_datasource/execution_plan_visitor.go
index f1ad122..50b39cc 100644
--- a/tmp/agent-patch-flux-pr-1209.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/v2/pkg/engine/datasource/grpc_datasource/execution_plan_visitor.go
+++ b/app/v2/pkg/engine/datasource/grpc_datasource/execution_plan_visitor.go
@@ -289,6 +289,7 @@ func (r *rpcPlanVisitor) handleRootField(ref int) error {
// EnterField implements astvisitor.EnterFieldVisitor.
func (r *rpcPlanVisitor) EnterField(ref int) {
fieldName := r.operation.FieldNameString(ref)
+ jsonPath := r.operation.FieldAliasOrNameString(ref)
if r.IsRootField() {
if err := r.handleRootField(ref); err != nil {
r.walker.StopWithInternalErr(err)
@@ -331,7 +332,7 @@ func (r *rpcPlanVisitor) EnterField(ref int) {
field := RPCField{
Name: r.resolveFieldMapping(parentTypeName, fieldName),
TypeName: typeName.String(),
- JSONPath: fieldName,
+ JSONPath: jsonPath,
Repeated: r.definition.TypeIsList(fdt),
}
diff --git a/tmp/agent-patch-flux-pr-1209.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/v2/pkg/engine/datasource/grpc_datasource/grpc_datasource_test.go b/app/v2/pkg/engine/datasource/grpc_datasource/grpc_datasource_test.go
index 71bf396..703deb8 100644
--- a/tmp/agent-patch-flux-pr-1209.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/v2/pkg/engine/datasource/grpc_datasource/grpc_datasource_test.go
+++ b/app/v2/pkg/engine/datasource/grpc_datasource/grpc_datasource_test.go
@@ -316,6 +316,52 @@ func Test_DataSource_Load_WithMockService_WithResponseMapping(t *testing.T) {
require.Equal(t, "HARDCODED_NAME_TEST", resp.Data.ComplexFilterType[0].Name)
}
+func Test_DataSource_Load_WithAlias(t *testing.T) {
+ conn, cleanup := setupTestGRPCServer(t)
+ t.Cleanup(cleanup)
+
+ query := `query AliasedUser($id: ID!) { aliasedUser: user(id: $id) { id userName: name } }`
+ variables := `{"variables":{"id":"alias-user"}}`
+
+ schemaDoc := grpctest.MustGraphQLSchema(t)
+ queryDoc, report := astparser.ParseGraphqlDocumentString(query)
+ if report.HasErrors() {
+ t.Fatalf("failed to parse query: %s", report.Error())
+ }
+
+ compiler, err := NewProtoCompiler(grpctest.MustProtoSchema(t), testMapping())
+ if err != nil {
+ t.Fatalf("failed to compile proto: %v", err)
+ }
+
+ ds, err := NewDataSource(conn, DataSourceConfig{
+ Operation: &queryDoc,
+ Definition: &schemaDoc,
+ SubgraphName: "Products",
+ Mapping: testMapping(),
+ Compiler: compiler,
+ })
+ require.NoError(t, err)
+
+ output := new(bytes.Buffer)
+ input := fmt.Sprintf(`{"query":%q,"body":%s}`, query, variables)
+ err = ds.Load(context.Background(), []byte(input), output)
+ require.NoError(t, err)
+
+ var resp struct {
+ Data map[string]map[string]interface{} `json:"data"`
+ }
+ require.NoError(t, json.Unmarshal(output.Bytes(), &resp))
+
+ user, ok := resp.Data["aliasedUser"]
+ require.True(t, ok, "aliased root field should be present")
+ require.Contains(t, user, "userName")
+ require.Equal(t, "User alias-user", user["userName"])
+ require.NotContains(t, user, "name")
+ _, ok = resp.Data["user"]
+ require.False(t, ok, "non-aliased root key should not exist")
+}
+
// Test_DataSource_Load_WithGrpcError tests how the datasource handles gRPC errors
// and formats them as GraphQL errors in the response
func Test_DataSource_Load_WithGrpcError(t *testing.T) {
diff --git a/tmp/agent-patch-flux-pr-1209.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/v2/pkg/engine/datasource/grpc_datasource/mapping_test_helper.go b/app/v2/pkg/engine/datasource/grpc_datasource/mapping_test_helper.go
index 10313fe..10231bc 100644
--- a/tmp/agent-patch-flux-pr-1209.1-of-1.2026-02-21__03-36-16__gpt-5-1-codex-mini/app/v2/pkg/engine/datasource/grpc_datasource/mapping_test_helper.go
+++ b/app/v2/pkg/engine/datasource/grpc_datasource/mapping_test_helper.go
@@ -484,6 +484,8 @@ func testMapping() *GRPCMapping {
TargetName: "category",
},
},
+ // ActionResult is the mutation union returned by performAction, so we map
+ // each member explicitly to the proto oneof fields.
"ActionResult": {
"actionSuccess": {
TargetName: "action_success",