Skip to content

Commit 6eff531

Browse files
fix(store): urn is not encoded when requesting to elasticsearch (#22)
1 parent d19eafd commit 6eff531

File tree

1 file changed

+4
-3
lines changed

1 file changed

+4
-3
lines changed

store/record_repository.go

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import (
77
"fmt"
88
"io"
99
"net/http"
10+
"net/url"
1011
"strings"
1112
"time"
1213

@@ -237,7 +238,7 @@ func (repo *RecordRepository) termsQuery(filters models.RecordFilter) (io.Reader
237238
func (repo *RecordRepository) GetByID(ctx context.Context, id string) (record models.Record, err error) {
238239
res, err := repo.cli.Get(
239240
repo.recordType.Name,
240-
id,
241+
url.PathEscape(id),
241242
repo.cli.Get.WithContext(ctx),
242243
)
243244
if err != nil {
@@ -251,7 +252,7 @@ func (repo *RecordRepository) GetByID(ctx context.Context, id string) (record mo
251252
err = models.ErrNoSuchRecord{RecordID: id}
252253
return
253254
}
254-
err = fmt.Errorf("error response from elasticsearch: %s", res.Status())
255+
err = fmt.Errorf("got %s response from elasticsearch: %s", res.Status(), res.String())
255256
return
256257
}
257258

@@ -269,7 +270,7 @@ func (repo *RecordRepository) GetByID(ctx context.Context, id string) (record mo
269270
func (repo *RecordRepository) Delete(ctx context.Context, id string) error {
270271
res, err := repo.cli.Delete(
271272
repo.recordType.Name,
272-
id,
273+
url.PathEscape(id),
273274
repo.cli.Delete.WithRefresh("true"),
274275
repo.cli.Delete.WithContext(ctx),
275276
)

0 commit comments

Comments
 (0)