Skip to content

Go SDK returning unexpected EOF when using batch insert #2519

@eduardodbr

Description

@eduardodbr

Which service(blob, file, queue, table) does this issue concern?

Table

Which version of the Azurite was used?

3.33.0
(also aztables 1.3.0)

Where do you get Azurite? (npm, DockerHub, NuGet, Visual Studio Code Extension)

DockerHub

What problem was encountered?

This seems similar to #1378

When trying to insert a batch in Azurite using Go SDK, the transaction fails with "Unexpected EOF".

Using the transaction type "InsertMerge" works, all the other ones are throwing the error.

Sample code:

func main() {
	sc, err := aztables.NewServiceClientFromConnectionString("DefaultEndpointsProtocol=http;AccountName=devstoreaccount1;AccountKey=Eby8vdM02xNOcqFlqUwJPLlmEtlCDXJ1OUzFT50uSRZ6IFsuFq2UVErCz4I6tq/K1SZFPTOtr/KBHBeksoGMGw==;TableEndpoint=http://127.0.0.1:10002/devstoreaccount1;", nil)
	if err != nil {
		panic(err)
	}
	client := sc.NewClient("TestTableBug")

	_, err = client.CreateTable(context.Background(), nil)
	if err != nil {
		var azErr *azcore.ResponseError
		if !errors.As(err, &azErr) {
			panic(err)
		}
		if azErr.StatusCode != http.StatusConflict {
			panic(err)
		}
	}

	entities := []aztables.EDMEntity{
		{
			Entity: aztables.Entity{
				PartitionKey: "foo",
				RowKey:       "rkey1",
			},
			Properties: map[string]interface{}{
				"product": "product1",
			},
		},
		{
			Entity: aztables.Entity{
				PartitionKey: "foo",
				RowKey:       "rkey2",
			},
			Properties: map[string]interface{}{
				"product": "product2",
			},
		},
	}
	var batch []aztables.TransactionAction
	for _, entity := range entities {
		b, err := entity.MarshalJSON()
		if err != nil {
			panic(err)
		}
		batch = append(batch, aztables.TransactionAction{
			ActionType: aztables.TransactionTypeInsertReplace, # with aztables.TransactionTypeInsertMerge works
			Entity:     b,
		})
	}
	resp, err := client.SubmitTransaction(context.Background(), batch, nil)
	if err != nil {
		panic(err) # -> will throw an "Unexpected EOF" error here
	}
	fmt.Println(resp)
}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions