{"record":{"id":"66bebbff2a05d94b","repo":"yuliskov/SmartTube","slug":"insert-is-not-implemented","errorCode":null,"errorMessage":"Insert is not implemented.","messagePattern":"Insert is not implemented\\.","errorType":"exception","errorClass":"UnsupportedOperationException","httpStatus":null,"severity":"error","filePath":"leanbackassistant/src/main/java/com/liskovsoft/leanbackassistant/search/VideoContentProvider.java","lineNumber":236,"sourceCode":"            mediaItem.getRatingStyle(),\n            mediaItem.getRatingScore(),\n            mediaItem.getProductionDate(),\n            mediaItem.getDurationMs(),\n            \"GLOBALSEARCH\",\n            mediaItem.getId()\n        };\n    }\n\n    @Nullable\n    @Override\n    public String getType(@NonNull Uri uri) {\n        return null;\n    }\n\n    @Nullable\n    @Override\n    public Uri insert(@NonNull Uri uri, @Nullable ContentValues contentValues) {\n        throw new UnsupportedOperationException(\"Insert is not implemented.\");\n    }\n\n    @Override\n    public int delete(@NonNull Uri uri, @Nullable String s, @Nullable String[] strings) {\n        throw new UnsupportedOperationException(\"Delete is not implemented.\");\n    }\n\n    @Override\n    public int update(\n            @NonNull Uri uri,\n            @Nullable ContentValues contentValues,\n            @Nullable String s,\n            @Nullable String[] strings) {\n        throw new UnsupportedOperationException(\"Update is not implemented.\");\n    }\n}\n","sourceCodeStart":218,"sourceCodeEnd":253,"githubUrl":"https://github.com/yuliskov/SmartTube/blob/3de8d90593e0166f012ca18cc3c7ba45bfd68ac4/leanbackassistant/src/main/java/com/liskovsoft/leanbackassistant/search/VideoContentProvider.java#L218-L253","documentation":"VideoContentProvider only implements query() for search suggestions; its data is a synthesized cache of MediaItems pulled from the media service, not a writable store. insert() therefore unconditionally throws UnsupportedOperationException('Insert is not implemented.') to fail fast on any write attempt.","triggerScenarios":"Any getContentResolver().insert(uri, values) call targeting this provider's authority; sync adapters or generic content tooling that assume every ContentProvider supports full CRUD.","commonSituations":"A generic sync framework or backup tool probing all declared providers; a developer assuming ContentProvider requires all six operations; automated tests iterating CRUD calls over every provider in the manifest.","solutions":["Do not call insert() on this provider — it is read-only by design; read search suggestions via query() only.","Route writes to the real data source (the app's channels/playlists and the media service APIs) instead of the search provider.","If you maintain a fork that genuinely needs writes, implement insert() against your own storage rather than leaving the throw."],"exampleFix":"// before\ngetContentResolver().insert(searchUri, values); // throws UnsupportedOperationException\n\n// after — the provider is read-only; write to the actual data source\n// (e.g. update channels/playlists through the app's own API) and only\n// query() the search provider.","handlingStrategy":"try-catch","validationCode":"// nothing to validate — insert is unconditionally unsupported;\n// just never call it on the search provider","typeGuard":null,"tryCatchPattern":"try {\n    getContentResolver().insert(searchUri, values);\n} catch (UnsupportedOperationException e) { // Insert is not implemented\n    Log.w(TAG, \"Search provider is read-only: \" + searchUri);\n    // route the write to the app's real data source instead\n}","preventionTips":["Treat VideoContentProvider as query-only; whitelist providers your sync code touches.","Keep a list of supported operations per authority in your sync layer instead of probing."],"tags":["android","content-provider","read-only","crud"],"backgroundTag":"read-only-content-provider","analyzedSha":"3de8d90593e0166f012ca18cc3c7ba45bfd68ac4","analyzedAt":"2026-08-22T09:19:26.383Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}