MCPcopy Create free account
hub / github.com/couchbase/sync_gateway / checkArguments

Method checkArguments

db/functions/function.go:203–221  ·  view source on GitHub ↗

FUNCTION PARAMETERS/ARGUMENTS: Checks that `args` contains exactly the same keys as the list `parameterNames`. Adds the special "context" parameter containing user data.

(args map[string]any)

Source from the content-addressed store, hash-verified

201// Checks that `args` contains exactly the same keys as the list `parameterNames`.
202// Adds the special "context" parameter containing user data.
203func (fn *functionImpl) checkArguments(args map[string]any) error {
204 // Make sure each specified parameter has a value in `args`:
205 for _, paramName := range fn.Args {
206 if _, found := args[paramName]; !found {
207 return base.HTTPErrorf(http.StatusBadRequest, "%s %q parameter %q is missing", fn.typeName, fn.name, paramName)
208 }
209 }
210
211 // Any extra parameters in `args` are illegal:
212 if len(args) > len(fn.Args) {
213 for _, paramName := range fn.Args {
214 delete(args, paramName)
215 }
216 for badKey := range args {
217 return base.HTTPErrorf(http.StatusBadRequest, "%s %q has no parameter %q", fn.typeName, fn.name, badKey)
218 }
219 }
220 return nil
221}
222
223//////// AUTHORIZATION:
224

Callers 1

InvokeMethod · 0.95

Calls 1

HTTPErrorfFunction · 0.92

Tested by

no test coverage detected