golem icon indicating copy to clipboard operation
golem copied to clipboard

Api Gateway Code issue: Avoid Validations of API definition that uses Gateway Variables

Open vigoo opened this issue 1 year ago • 1 comments

GatewayVariables in api-gateway are basically values of variables based on a request-body, request-header, worker-response etc. Say , if api-definition (the actual Api Spec in yaml) that user uploads can have something like

function-params: ["${request.header.auth}", "${request.body.username}"] Currently we validate this by actually forming gateway variables (apparently) which can confuse the workflow and maintainability of gateway codebase. This has to be avoided. A GatewayVariable (tomorrow this will be in terms of wasm Val) can be formed only when user fires an actual request (and not during validation which happens only when they upload an API definition,)

Example:

fn function_variables(function_params: &Expr) -> GatewayVariables {
    let mut variables = GatewayVariables::new();

    let paths = function_params.get_paths();

    for path in paths {
        variables.insert(path.clone(), Value::String("".to_string()));
    }

    let path_vars = function_params.get_path_vars();

    for var in path_vars {
        variables.insert_primitives(var.as_str(), "");
    }

    variables
}

vigoo avatar Mar 17 '24 12:03 vigoo

See https://github.com/golemcloud/golem-cloud/issues/1027 for previous discussion

vigoo avatar Mar 17 '24 12:03 vigoo

Closing as we are going to delete the Rib based API gateway

vigoo avatar Aug 18 '25 18:08 vigoo