{"record":{"id":"3e47cd515b8dc7be","repo":"microg/GmsCore","slug":"a-path-must-start-with-a-single","errorCode":null,"errorMessage":"A path must start with a single / .","messagePattern":"A path must start with a single / \\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"play-services-wearable/src/main/java/com/google/android/gms/wearable/internal/PutDataRequest.java","lineNumber":71,"sourceCode":"    private PutDataRequest() {\n        uri = null;\n        assets = new Bundle();\n    }\n\n    private PutDataRequest(Uri uri) {\n        this.uri = uri;\n        assets = new Bundle();\n    }\n\n    public static PutDataRequest create(Uri uri) {\n        return new PutDataRequest(uri);\n    }\n\n    public static PutDataRequest create(String path) {\n        if (TextUtils.isEmpty(path)) {\n            throw new IllegalArgumentException(\"An empty path was supplied.\");\n        } else if (!path.startsWith(\"/\")) {\n            throw new IllegalArgumentException(\"A path must start with a single / .\");\n        } else if (path.startsWith(\"//\")) {\n            throw new IllegalArgumentException(\"A path must start with a single / .\");\n        } else {\n            return create((new Uri.Builder()).scheme(WEAR_URI_SCHEME).path(path).build());\n        }\n    }\n\n    public static PutDataRequest createFromDataItem(DataItem source) {\n        PutDataRequest dataRequest = new PutDataRequest(source.getUri());\n        dataRequest.data = source.getData();\n        // TODO: assets\n        return dataRequest;\n    }\n\n    public static PutDataRequest createWithAutoAppendedId(String pathPrefix) {\n        return new PutDataRequest(null);\n    }\n","sourceCodeStart":53,"sourceCodeEnd":89,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-wearable/src/main/java/com/google/android/gms/wearable/internal/PutDataRequest.java#L53-L89","documentation":"PutDataRequest.create(String path) requires the path to start with exactly one '/'. If the path does not begin with '/', the library throws IllegalArgumentException(\"A path must start with a single / .\") because a wear:// URI cannot be built from a relative path.","triggerScenarios":"Calling PutDataRequest.create(\"foo\") or create(\"data/item\") — a non-empty path whose first character is not '/'.","commonSituations":"Passing just a key name instead of a path; stripping the leading slash in string manipulation; using a path fragment copied from documentation without the leading '/'.","solutions":["Prepend '/' to the path if missing before calling create().","Use DataMap or PutDataRequest.create(Uri) with a properly built wear:// Uri if you need more control.","Normalize paths through a helper that guarantees a leading slash."],"exampleFix":"// before\nPutDataRequest request = PutDataRequest.create(\"steps\");\n\n// after\nif (!path.startsWith(\"/\")) {\n    path = \"/\" + path;\n}\nPutDataRequest request = PutDataRequest.create(path);","handlingStrategy":"validation","validationCode":"if (path != null && !path.startsWith(\"/\")) path = \"/\" + path;","typeGuard":null,"tryCatchPattern":"try {\n    PutDataRequest.create(path);\n} catch (IllegalArgumentException e) {\n    PutDataRequest.create(\"/\" + path);\n}","preventionTips":["Wear paths are always absolute; keep the leading slash","Review string transforms that could strip the slash"],"tags":["android","wearable","argument-validation","uri"],"backgroundTag":"invalid-argument-format","analyzedSha":"157c9d86ac46c195a86c2f15ab55c84036223f95","analyzedAt":"2026-09-06T17:27:33.892Z","contentChangedAt":"2026-09-06T17:27:33.892Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}