diff --git a/packages/common/formatted-error/errors/route/invalid_name_id.md b/packages/common/formatted-error/errors/route/invalid_name_id.md index 451cfdbe51..64b48f9f6e 100644 --- a/packages/common/formatted-error/errors/route/invalid_name_id.md +++ b/packages/common/formatted-error/errors/route/invalid_name_id.md @@ -5,7 +5,7 @@ description_basic = "The route name_id format is invalid." http_status = 400 --- -# invalid_name_id +# Invalid Name ID The name_id provided for the route is invalid. Route name_ids must be lowercase alphanumeric or dashes without repeating double dashes, and are limited to 16 characters. @@ -22,4 +22,4 @@ Make sure your name_id: ### Examples Invalid: `UPPERCASE-route`, `route--name`, `-route-name`, `route-name-` -Valid: `my-route`, `route-123`, `api-v2` \ No newline at end of file +Valid: `my-route`, `route-123`, `api-v2` diff --git a/packages/toolchain/cli/src/util/deploy.rs b/packages/toolchain/cli/src/util/deploy.rs index c3e8eecfa1..4b6a9e585c 100644 --- a/packages/toolchain/cli/src/util/deploy.rs +++ b/packages/toolchain/cli/src/util/deploy.rs @@ -394,55 +394,41 @@ async fn create_function_route( route_tags: &HashMap, default_hostname: &str, ) -> Result<()> { - // Get route_subpaths and strip_prefix from config let default_route_subpaths = function.route_subpaths.unwrap_or(true); let default_strip_prefix = function.strip_prefix.unwrap_or(true); - // Loop until route creation succeeds - let mut route_created = false; - while !route_created { - let hostname = default_hostname.to_string(); - let path = function.path(); - let route_subpaths = default_route_subpaths; - let strip_prefix = default_strip_prefix; - - // Prepare route body - let update_route_body = models::RoutesUpdateRouteBody { - hostname, - path, - route_subpaths, - strip_prefix, - target: Box::new(models::RoutesRouteTarget { - actors: Some(Box::new(models::RoutesRouteTargetActors { - selector_tags: route_tags.clone(), - })), - }), - }; - - // Create/update route - let result = apis::routes_api::routes_update( - &ctx.openapi_config_cloud, - &fn_name, - update_route_body.clone(), - Some(&ctx.project.name_id.to_string()), - Some(&environment.slug), - ) - .await; - - match result { - Result::Ok(_) => { - println!( - "Successfully created route: {}{}", - update_route_body.hostname, update_route_body.path - ); - route_created = true; - } - Err(err) => { - eprintln!("Failed to create route: {}", err); - break; - } - } - } + let hostname = default_hostname.to_string(); + let path = function.path(); + let route_subpaths = default_route_subpaths; + let strip_prefix = default_strip_prefix; + + // Prepare route body + let update_route_body = models::RoutesUpdateRouteBody { + hostname, + path, + route_subpaths, + strip_prefix, + target: Box::new(models::RoutesRouteTarget { + actors: Some(Box::new(models::RoutesRouteTargetActors { + selector_tags: route_tags.clone(), + })), + }), + }; + + // Create/update route + apis::routes_api::routes_update( + &ctx.openapi_config_cloud, + &fn_name, + update_route_body.clone(), + Some(&ctx.project.name_id.to_string()), + Some(&environment.slug), + ) + .await?; + + println!( + "Successfully created route: {}{}", + update_route_body.hostname, update_route_body.path + ); Ok(()) }