{"record":{"id":"3a0fd03e9517212b","repo":"microg/GmsCore","slug":"an-empty-path-was-supplied","errorCode":null,"errorMessage":"An empty path was supplied.","messagePattern":"An empty path was supplied\\.","errorType":"validation","errorClass":"IllegalArgumentException","httpStatus":null,"severity":"error","filePath":"play-services-wearable/src/main/java/com/google/android/gms/wearable/internal/PutDataRequest.java","lineNumber":69,"sourceCode":"    long syncDeadline = DEFAULT_SYNC_DEADLINE;\n\n    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);","sourceCodeStart":51,"sourceCodeEnd":87,"githubUrl":"https://github.com/microg/GmsCore/blob/157c9d86ac46c195a86c2f15ab55c84036223f95/play-services-wearable/src/main/java/com/google/android/gms/wearable/internal/PutDataRequest.java#L51-L87","documentation":"PutDataRequest.create(String path) validates the path before building a wear:// Uri. An empty or null path cannot form a valid wear URI, so the library throws IllegalArgumentException(\"An empty path was supplied.\").","triggerScenarios":"Calling PutDataRequest.create(\"\") or PutDataRequest.create(null) — any path that TextUtils.isEmpty treats as empty.","commonSituations":"Building the path dynamically from a database value or user input that is empty; forgetting to set a constant path field; concatenating segments where the variable part is missing.","solutions":["Check the path for null/emptiness before calling create and provide a valid path starting with '/'.","Log the source of the path value to find why it is empty.","Provide a default path constant instead of dynamic construction."],"exampleFix":"// before\nPutDataRequest request = PutDataRequest.create(path);\n\n// after\nif (path == null || path.isEmpty()) {\n    throw new IllegalStateException(\"path must be set before syncing\");\n}\nPutDataRequest request = PutDataRequest.create(path);","handlingStrategy":"validation","validationCode":"if (TextUtils.isEmpty(path)) { throw new IllegalArgumentException(\"path required\"); }","typeGuard":null,"tryCatchPattern":"try {\n    PutDataRequest.create(path);\n} catch (IllegalArgumentException e) {\n    Log.e(TAG, \"empty path\", e);\n}","preventionTips":["Assert path constants non-empty in init","Never derive paths from nullable fields without a default","Use Uri-based create with pre-built wear:// Uri for complex cases"],"tags":["android","wearable","argument-validation"],"backgroundTag":"empty-required-field","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"}