Skip to content

Commit 33de478

Browse files
committed
fixes based on PR comments
1 parent b8e7403 commit 33de478

File tree

3 files changed

+6
-11
lines changed

3 files changed

+6
-11
lines changed

base/error.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -404,7 +404,7 @@ func (e *ImportFilterDryRunError) Error() string {
404404
if e.Err == nil {
405405
return importFilterErrorPrefix
406406
}
407-
return e.Err.Error()
407+
return importFilterErrorPrefix+ ": " + e.Err.Error()
408408
}
409409

410410
func (e *ImportFilterDryRunError) Unwrap() error {

rest/diagnostic_doc_api.go

Lines changed: 2 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -184,10 +184,8 @@ func (h *handler) handleImportFilterDryRun() error {
184184

185185
var importFilterPayload ImportFilterDryRunPayload
186186
err := h.readJSONInto(&importFilterPayload)
187-
// Only require a valid JSON payload if docid is not provided.
188-
// If docid is provided, the sync function will use the document from the bucket, and the payload is optional.
189-
if err != nil && docid == "" {
190-
return base.HTTPErrorf(http.StatusBadRequest, "Error reading sync function payload: %v", err)
187+
if err != nil {
188+
return base.HTTPErrorf(http.StatusBadRequest, "Error reading import filter payload: %v", err)
191189
}
192190

193191
// Cannot pass both doc_id and body in the request body
@@ -213,9 +211,6 @@ func (h *handler) handleImportFilterDryRun() error {
213211
return err
214212
}
215213
errorMsg = err.Error()
216-
if importFilterDryRunErr.Unwrap() != nil {
217-
errorMsg = importFilterDryRunErr.Err.Error()
218-
}
219214
}
220215
resp := ImportFilterDryRun{
221216
shouldImport,

rest/diagnostic_doc_api_test.go

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1239,7 +1239,7 @@ func TestImportFilterDryRun(t *testing.T) {
12391239
document: map[string]any{"accessUser": "user"},
12401240
existingDoc: false,
12411241
expectedOutput: ImportFilterDryRun{
1242-
Error: "TypeError: Cannot access member 'num' of undefined",
1242+
Error: "Error returned from Import Filter: TypeError: Cannot access member 'num' of undefined",
12431243
},
12441244
expectedStatus: http.StatusOK,
12451245
},
@@ -1249,7 +1249,7 @@ func TestImportFilterDryRun(t *testing.T) {
12491249
document: map[string]any{"accessUser": "user"},
12501250
existingDoc: false,
12511251
expectedOutput: ImportFilterDryRun{
1252-
Error: "TypeError: Cannot access member 'num' of undefined",
1252+
Error: "Error returned from Import Filter: TypeError: Cannot access member 'num' of undefined",
12531253
},
12541254
expectedStatus: http.StatusOK,
12551255
},
@@ -1260,7 +1260,7 @@ func TestImportFilterDryRun(t *testing.T) {
12601260
document: map[string]any{"accessUser": "user"},
12611261
existingDoc: false,
12621262
expectedOutput: ImportFilterDryRun{
1263-
Error: "TypeError: Cannot access member 'num' of undefined",
1263+
Error: "Error returned from Import Filter: TypeError: Cannot access member 'num' of undefined",
12641264
},
12651265
expectedStatus: http.StatusOK,
12661266
},

0 commit comments

Comments
 (0)