AppProxy returns HTML instead of JSON for invalid API parameters
- Dominant language
- Python
- Stars
- 670
- Forks
- 183
- Avg merge
- 17h 7m
- Merged PRs (30d)
- 358
Description
## Summary
When the AppProxy receives invalid or malformed API parameters, it responds with an HTML error page instead of a JSON-formatted error response. This behavior breaks clients expecting a structured API response.
POST /v2/endpoints/{endpoint_id}
[https://github.com/lablup/backend.ai/blob/e62b356ef330fbe1c0b02c504a0e53d044d7cc52/src/ai/backend/wsproxy/api/utils.py#L240-L241](https://github.com/lablup/backend.ai/blob/e62b356ef330fbe1c0b02c504a0e53d044d7cc52/src/ai/backend/wsproxy/api/utils.py#L240-L241)
## Steps to Reproduce
```python
resp = sess.Service.create(
self.config["environment"]["image"],
model_id_or_name=self.config["service"]["model"],
initial_session_count=self.config["service"]["replicas"],
service_name=service_name,
runtime_variant=self.config["service"].get("runtime_variant"),
model_mount_destination=model_mount_destination,
model_definition_path=self.config["service"].get("model_definition_path"),
cluster_mode=cluster_mode,
cluster_size=cluster_size,
extra_mounts=mounts, # TODO: No model-type folders here
extra_mount_map=mount_map,
extra_mount_options=mount_options,
envs={**self.config["environment"]["envs"], **envs},
resources=self.config["resources"],
resource_opts=self.config.get("resource_opts", {}),
domain_name=ownership["domain_name"],
group_name=ownership["project"],
scaling_group=ownership["scaling-group"],
expose_to_public=config.open_to_public,
)
```
## Expected Behavior
-
## Actual Behavior
-
## Logs/Errors
```
2025-07-21 14:20:27.741 INFO ai.backend.manager.registry [25961] Created endpoint 09998a83-250a-4c1c-b662-8b77e33ec119 on appproxy:
html{font-family:sans-serif;line-height:1.15;-ms-text-size-adjust:100%;-webkit-text-size-adjust:100%}body{margin:0}article,aside,footer,header,nav,section{display:block}h1{font-size:2em;margin:.67em 0}figcaption,figure,main{display:block}figure{margin:1em 40px}hr{box-sizing:content-box;height:0;overflow:visible}pre{font-family:monospace,monospace;font-size:1em}a{background-color:transparent;-webkit-text-decoration-skip:objects}a:active,a:hover{outline-width:0}abbr[title]{border-bottom:none;text-decoration:underline;text-decoration:underline dotted}b,strong{font-weight:inherit}b,strong{font-weight:bolder}code,kbd,samp{font-family:monospace,monospace;font-size:1em}dfn{font-style:italic}mark{background-color:#ff0;color:#000}small{font-size:80%}sub,sup{font-size:75%;line-height:0;position:relative;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}audio,video{display:inline-block}audio:not([controls]){display:none;height:0}img{border-style:none}svg:not(:root){overflow:hidden}button,input,optgroup,select,textarea{font-family:sans-serif;font-size:100%;line-height:1.15;margin:0}button,input{overflow:visible}button,select{text-transform:none}[type=reset],[type=submit],button,html [type=button]{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{border-style:none;padding:0}[type=button]:-moz-focusring,[type=reset]:-moz-focusring,[type=submit]:-moz-focusring,button:-moz-focusring{outline:1px dotted ButtonText}fieldset{border:1px solid silver;margin:0 2px;padding:.35em .625em .75em}legend{box-sizing:border-box;color:inherit;display:table;max-width:100%;padding:0;white-space:normal}progress{display:inline-block;vertical-align:baseline}textarea{overflow:auto}[type=checkbox],[type=radio]{box-sizing:border-box;padding:0}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{-webkit-appearance:textfield;outline-offset:-2px}[type=search]::-webkit-search-cancel-button,[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{-webkit-appearance:button;font:inherit}details,menu{display:block}summary{display:list-item}canvas{display:inline-block}template{display:none}[hidden]{display:none}body,html{width:100%;height:100%;background-color:#fff}body{color:#444;text-align:center;padding:0;min-height:100%;-webkit-box-shadow:inset 0 0 100px rgba(224, 226, 215,.2);box-shadow:inset 0 0 100px rgba(224, 226, 215,.2);display:table;font-family:"Open Sans",Arial,sans-serif}h1{font-family:inherit;font-weight:500;line-height:1.1;color:inherit;font-size:36px}h1 small{font-size:68%;font-weight:400;line-height:1;color:#777}a{text-decoration:none;color:#777;font-size:inherit;border-bottom:dotted 1px #707070}.lead{color:silver;font-size:21px;line-height:1.4}.cover{display:table-cell;vertical-align:middle;padding:0 20px}footer{position:fixed;width:100%;height:40px;left:0;bottom:0;color:#777;font-size:14px}
Backend.AI
Missing or invalid API parameters.
[{'type': 'missing', 'loc': ('apps',), 'msg': 'Field required', 'input': {'version': 'v2', 'service_name': 'simple-http-service', 'tags': {'session': {'user_uuid': '3f2db04a-b299-4c7f-9e39-1016c881ea8d', 'group_id': '2de2b969-1d04-48a6-af16-0bc8adb3c831', 'domain_name': 'default'}, 'endpoint': {'id': '09998a83-250a-4c1c-b662-8b77e33ec119', 'runtime_variant': 'custom', 'existing_url': None}}, 'open_to_public': True, 'health_check': {'interval': 10.0, 'path': '/health', 'max_retries': 5, 'max_wait_time': 15.0, 'expected_status_code': 200}}, 'url': 'https://errors.pydantic.dev/2.11/v/missing'}] Input validation error
```
JIRA Issue: BA-1929
Contributor guide
Assessment
This issue has not been assessed yet.