Skip to content

Commit 5966ed4

Browse files
committed
Make the server more permissive
1 parent b751eca commit 5966ed4

File tree

1 file changed

+21
-7
lines changed

1 file changed

+21
-7
lines changed

backend/app/routers/upload.py

Lines changed: 21 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -180,10 +180,23 @@ async def upload_worker_run(
180180
# Validate configure flags - the registered binary flags must be a subset of uploaded flags
181181
configure_vars = metadata.get("configure_vars", {})
182182
uploaded_config_args = configure_vars.get("CONFIG_ARGS", "")
183-
uploaded_flags = (
184-
set(uploaded_config_args.split()) if uploaded_config_args else set()
185-
)
186-
registered_flags = set(binary.flags) if binary.flags else set()
183+
184+
# Strip quotes from each flag and filter out non-configure flags
185+
def clean_flag(flag):
186+
"""Remove surrounding quotes from a flag."""
187+
return flag.strip().strip("'\"")
188+
189+
# Split and clean uploaded flags, filtering out environment variables
190+
raw_uploaded_flags = uploaded_config_args.split() if uploaded_config_args else []
191+
uploaded_flags = set()
192+
for flag in raw_uploaded_flags:
193+
cleaned = clean_flag(flag)
194+
# Only include flags that start with -- (configure flags)
195+
if cleaned.startswith('--'):
196+
uploaded_flags.add(cleaned)
197+
198+
# Clean registered flags too for consistency
199+
registered_flags = {clean_flag(flag) for flag in (binary.flags or [])}
187200

188201
logger.debug(
189202
f"Configure flags validation: registered={sorted(registered_flags)}, uploaded={sorted(uploaded_flags)}"
@@ -197,12 +210,13 @@ async def upload_worker_run(
197210
f"Upload failed: Configure flags mismatch for binary '{binary_id}'. "
198211
f"Missing flags: {sorted(missing_flags)}, "
199212
f"Required: {sorted(registered_flags)}, "
200-
f"Provided: {sorted(uploaded_flags)}"
213+
f"Provided: {sorted(uploaded_flags)}, "
214+
f"Raw CONFIG_ARGS: '{uploaded_config_args}'"
201215
)
202216
raise HTTPException(
203217
status_code=400,
204-
detail=f"Binary '{binary_id}' requires configure flags {sorted(missing_flags)} but upload only has {sorted(uploaded_flags)}. "
205-
f"Registered configure flags {sorted(registered_flags)} must be a subset of upload configure flags.",
218+
detail=f"Binary '{binary_id}' requires configure flags {sorted(list(registered_flags))} but upload only has {sorted(list(uploaded_flags))}. "
219+
f"Registered configure flags must be a subset of upload configure flags.",
206220
)
207221
logger.info(f"Configure flags validation passed for binary '{binary_id}'")
208222

0 commit comments

Comments
 (0)