Skip to content

armgit / macro

Public Imported from GitHub
0

Macro is a unified workspace for teams: email, chat, docs, tasks, agents, calls, and CRM — @-linked together with shared AI memory.

fix(local-stack): reach the static file service in-network, permalinks via the proxy (#6466)

Wolf Mermelsteinc2858a9e175d
diff --git a/tooling/xtask/crates/xtask_local/src/local/local_env.rs b/tooling/xtask/crates/xtask_local/src/local/local_env.rs
index 4fccf8ff92..87556bccf6 100644
--- a/tooling/xtask/crates/xtask_local/src/local/local_env.rs
+++ b/tooling/xtask/crates/xtask_local/src/local/local_env.rs
@@ -31,6 +31,13 @@ pub struct LocalEnv {
frontend_port: u16,
/// Browser-facing route to document cognition's MCP OAuth callback.
mcp_public_url: String,
+ /// Browser-facing base the static file service stamps into permalinks.
+ /// Only the service itself reads `STATIC_FILE_SERVICE_URL`; callers
+ /// reach it in-network through the `OVERRIDE_` form below. Without this
+ /// a named instance mints `http://localhost:8100/file/...`, the
+ /// single-instance CDN port, which nothing on a named instance serves;
+ /// the proxy's `/static-file/*` block is what does.
+ static_file_public_url: String,
infra: InfraEnv,
storage: StorageEnv,
queues: QueueEnv,
@@ -66,6 +73,10 @@ impl LocalEnv {
instance.port(Port::Frontend)
},
mcp_public_url: format!("http://localhost:{}/cognition", instance.port(Port::Proxy)),
+ static_file_public_url: format!(
+ "http://localhost:{}/static-file",
+ instance.port(Port::Proxy)
+ ),
infra: InfraEnv::local(),
storage: StorageEnv::local(),
queues: QueueEnv::local(),
@@ -85,6 +96,10 @@ impl LocalEnv {
env.insert("PORT".into(), "8080".into());
env.insert("FRONTEND_PORT".into(), self.frontend_port.to_string());
env.insert("MCP_PUBLIC_URL".into(), self.mcp_public_url.clone());
+ env.insert(
+ "STATIC_FILE_SERVICE_URL".into(),
+ self.static_file_public_url.clone(),
+ );
// Pipedream's hosted Connect UI refuses to be opened from an origin
// outside this list, and document_cognition's own local default only
// names port 3000 - a named instance's frontend lives on a derived
@@ -194,6 +209,14 @@ impl InfraEnv {
"OVERRIDE_AUTH_SERVICE_URL".into(),
"http://authentication-service:8080".into(),
);
+ // Same split for the static file service: without this a service
+ // storing a file (the agent harness re-hosting a Cursor artifact)
+ // asks http://localhost:8100, the host port of the single-instance
+ // CDN, which inside a container is the caller itself.
+ env.insert(
+ "OVERRIDE_STATIC_FILE_SERVICE_URL".into(),
+ "http://static-file-service:8080".into(),
+ );
// The alias LocalStack provisions for the Cursor API key CMK. Named by
// alias rather than key id because `CreateKey` mints a random id every
// run, and KMS accepts an alias anywhere a key id goes. Required by
diff --git a/tooling/xtask/crates/xtask_local/src/local/local_env/test.rs b/tooling/xtask/crates/xtask_local/src/local/local_env/test.rs
index 04b2f76816..8992cabbac 100644
--- a/tooling/xtask/crates/xtask_local/src/local/local_env/test.rs
+++ b/tooling/xtask/crates/xtask_local/src/local/local_env/test.rs
@@ -205,6 +205,10 @@ fn emits_in_network_service_url_overrides() {
"OVERRIDE_DOCUMENT_STORAGE_SERVICE_URL",
"http://document-storage-service:8080",
),
+ (
+ "OVERRIDE_STATIC_FILE_SERVICE_URL",
+ "http://static-file-service:8080",
+ ),
(
"OVERRIDE_LEXICAL_SERVICE_URL",
"http://lexical-service:8096",
@@ -214,6 +218,23 @@ fn emits_in_network_service_url_overrides() {
}
}
+/// Permalinks the static file service mints must be loadable by a browser on
+/// the host: the instance proxy's `/static-file/*` block, not the
+/// single-instance CDN port.
+#[test]
+fn static_file_permalinks_go_through_the_instance_proxy() {
+ let env = local_env();
+ let permalink_base = env
+ .get("STATIC_FILE_SERVICE_URL")
+ .expect("static file permalink base");
+ assert!(
+ permalink_base.starts_with("http://localhost:"),
+ "{permalink_base}"
+ );
+ assert!(permalink_base.ends_with("/static-file"), "{permalink_base}");
+ assert!(!permalink_base.contains(":8100"), "{permalink_base}");
+}
+
/// The auth service presents `SERVICE_INTERNAL_AUTH_KEY` to document storage,
/// which validates against `DOCUMENT_STORAGE_SERVICE_AUTH_KEY`. Dev/prod point
/// both at one secret; locally they must match too or every auth-service