-
Notifications
You must be signed in to change notification settings - Fork 141
CBG-4411: Improvements to Diagnostic Sync Function dry run endpoint #7932
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
a5c40f1
17a8d02
2be664d
5ac4762
7996317
0322417
e38a8fc
babaaf6
f8e41bf
db2533b
335a118
deca9d3
7374205
e1e69a6
68a452c
17034a4
8afb4bf
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||
|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -11,6 +11,7 @@ licenses/APL2.txt. | |||||||||
| package rest | ||||||||||
|
|
||||||||||
| import ( | ||||||||||
| "errors" | ||||||||||
| "fmt" | ||||||||||
| "net/http" | ||||||||||
|
|
||||||||||
|
|
@@ -33,6 +34,11 @@ type ImportFilterDryRun struct { | |||||||||
| Error string `json:"error"` | ||||||||||
| } | ||||||||||
|
|
||||||||||
| type SyncFnDryRunPayload struct { | ||||||||||
| Function string `json:"sync_function"` | ||||||||||
| Doc db.Body `json:"doc,omitempty"` | ||||||||||
| } | ||||||||||
|
|
||||||||||
| func populateDocChannelInfo(doc db.Document) map[string][]auth.GrantHistorySequencePair { | ||||||||||
| resp := make(map[string][]auth.GrantHistorySequencePair, len(doc.Channels)) | ||||||||||
|
|
||||||||||
|
|
@@ -70,20 +76,84 @@ func (h *handler) handleGetDocChannels() error { | |||||||||
| func (h *handler) handleSyncFnDryRun() error { | ||||||||||
| docid := h.getQuery("doc_id") | ||||||||||
|
|
||||||||||
| body, err := h.readDocument() | ||||||||||
| var syncDryRunPayload SyncFnDryRunPayload | ||||||||||
| err := h.readJSONInto(&syncDryRunPayload) | ||||||||||
|
||||||||||
| err := h.readJSONInto(&syncDryRunPayload) | |
| err := h.readJSONInto(&syncDryRunPayload) | |
| // Only require a valid JSON payload if docid is not provided. | |
| // If docid is provided, the sync function will use the document from the bucket, and the payload is optional. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I agree with this comment.
Based on the table in the API documentation describing how this endpoint works - in the case where you provide a doc ID to act as oldDoc, and provide some invalid JSON for doc - this error will be a silent failure (running the sync function on an empty body).
This should be able to be covered by a unit test case.
Uh oh!
There was an error while loading. Please reload this page.