{"record":{"id":"d25da9f586da05d8","repo":"multica-ai/multica","slug":"w-s","errorCode":null,"errorMessage":"%w: %s","messagePattern":"%w: %s","errorType":"exception","errorClass":"ErrInvalidBaseURL","httpStatus":null,"severity":"error","filePath":"server/internal/cloudruntime/client.go","lineNumber":129,"sourceCode":"func (c *Client) Do(ctx context.Context, req Request) (*Response, error) {\n\tif c == nil || c.baseURL == \"\" {\n\t\treturn nil, ErrDisabled\n\t}\n\n\top := inferCloudRuntimeOp(req.Op, req.Method, req.Path)\n\tstart := time.Now()\n\tresp, err := c.doInner(ctx, req)\n\tif c.recorder != nil {\n\t\tstatus := requestStatusBucket(resp, err)\n\t\tc.recorder.RecordCloudRuntimeRequest(op, status, time.Since(start).Seconds())\n\t}\n\treturn resp, err\n}\n\nfunc (c *Client) doInner(ctx context.Context, req Request) (*Response, error) {\n\tbase, err := url.Parse(c.baseURL)\n\tif err != nil || base.Scheme == \"\" || base.Host == \"\" {\n\t\treturn nil, fmt.Errorf(\"%w: %s\", ErrInvalidBaseURL, c.baseURL)\n\t}\n\tif !strings.HasPrefix(req.Path, \"/\") {\n\t\treturn nil, fmt.Errorf(\"cloud runtime path must start with /: %s\", req.Path)\n\t}\n\n\tu := *base\n\tu.Path = strings.TrimRight(base.Path, \"/\") + req.Path\n\tu.RawQuery = req.Query.Encode()\n\n\tvar body io.Reader\n\tif len(req.Body) > 0 {\n\t\tbody = bytes.NewReader(req.Body)\n\t}\n\thttpReq, err := http.NewRequestWithContext(ctx, req.Method, u.String(), body)\n\tif err != nil {\n\t\treturn nil, err\n\t}\n\thttpReq.Header.Set(\"Accept\", \"application/json\")","sourceCodeStart":111,"sourceCodeEnd":147,"githubUrl":"https://github.com/multica-ai/multica/blob/2c0912b6ec764b373d44eeea1e80f0d9f11ab417/server/internal/cloudruntime/client.go#L111-L147","documentation":"Cloudruntime Client.doInner rejects the configured base URL: url.Parse failed or the parsed URL lacks a scheme/host, and the error wraps the sentinel ErrInvalidBaseURL. The '%w: %s' format preserves errors.Is(err, ErrInvalidBaseURL) while showing the offending value, so callers can distinguish misconfiguration from transport failures.","triggerScenarios":"Constructing or calling the cloud runtime client with baseURL set to '', 'localhost:8080' (no scheme), 'http://' (no host), or a value with embedded whitespace/control characters. Also a baseURL sourced from an env var or server config that was never validated.","commonSituations":"MULTICA_* env var typos, config files with empty/placeholder URLs ('TODO'), URLs copied with a leading space, or a URL built by string concatenation that dropped the scheme.","solutions":["Set a complete base URL including scheme and host, e.g. 'https://runtime.example.com'","Validate the URL once at startup (url.Parse + scheme/host check) and fail configuration, not per-request","Check where the client's baseURL comes from (env/config flag) and confirm the value actually reaches the constructor"],"exampleFix":"// before\nbase, err := url.Parse(c.baseURL)\nif err != nil || base.Scheme == \"\" || base.Host == \"\" {\n    return nil, fmt.Errorf(\"%w: %s\", ErrInvalidBaseURL, c.baseURL)\n}\n\n// after (caller side): validate at construction so requests never carry a bad URL\nif _, err := url.Parse(baseURL); err != nil {\n    return nil, fmt.Errorf(\"base URL: %w\", err)\n}\nu, _ := url.Parse(baseURL)\nif u.Scheme == \"\" || u.Host == \"\" {\n    return nil, fmt.Errorf(\"base URL %q must include scheme and host\", baseURL)\n}","handlingStrategy":"validation","validationCode":"// Validate before constructing/using the client.\nfunc ValidBaseURL(raw string) bool {\n    u, err := url.Parse(strings.TrimSpace(raw))\n    return err == nil && u.Scheme != \"\" && u.Host != \"\"\n}\n\nif !ValidBaseURL(cfg.CloudRuntimeURL) {\n    return fmt.Errorf(\"cloud runtime URL %q must include scheme and host\", cfg.CloudRuntimeURL)\n}","typeGuard":null,"tryCatchPattern":"Check errors.Is(err, cloudruntime.ErrInvalidBaseURL) and route to configuration-error handling (fail fast at startup) rather than generic request-failure handling.","preventionTips":["Validate URLs once at config load, not per request","Source base URLs from typed config, never raw env strings","Unit-test the client with an httptest server so malformed URLs never reach production"],"tags":["cloud-runtime","config","url","validation"],"backgroundTag":null,"analyzedSha":"2c0912b6ec764b373d44eeea1e80f0d9f11ab417","analyzedAt":"2026-08-15T13:25:18.241Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}