{"record":{"id":"b04adb7dd90ce94a","repo":"Tencent/tinker","slug":"getpatchpathextra-but-intent-is-null","errorCode":null,"errorMessage":"getPatchPathExtra, but intent is null","messagePattern":"getPatchPathExtra, but intent is null","errorType":"exception","errorClass":"TinkerRuntimeException","httpStatus":null,"severity":"error","filePath":"tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/service/TinkerPatchService.java","lineNumber":92,"sourceCode":"        } catch (Throwable thr) {\n            ShareTinkerLog.e(TAG, \"run patch service fail, exception:\" + thr);\n        }\n    }\n\n    public static void setPatchProcessor(AbstractPatch upgradePatch, Class<? extends AbstractResultService> serviceClass) {\n        upgradePatchProcessor = upgradePatch;\n        resultServiceClass = serviceClass;\n        //try to load\n        try {\n            Class.forName(serviceClass.getName());\n        } catch (ClassNotFoundException e) {\n            ShareTinkerLog.printErrStackTrace(TAG, e, \"patch processor class not found.\");\n        }\n    }\n\n    public static String getPatchPathExtra(Intent intent) {\n        if (intent == null) {\n            throw new TinkerRuntimeException(\"getPatchPathExtra, but intent is null\");\n        }\n        return ShareIntentUtil.getStringExtra(intent, PATCH_PATH_EXTRA);\n    }\n\n    public static boolean getPatchUseEmergencyMode(Intent intent) {\n        if (intent == null) {\n            throw new TinkerRuntimeException(\"getPatchUseEmergencyMode, but intent is null\");\n        }\n        return ShareIntentUtil.getBooleanExtra(intent, PATCH_USE_EMERGENCY_MODE, false);\n    }\n\n    public static String getPatchResultExtra(Intent intent) {\n        if (intent == null) {\n            throw new TinkerRuntimeException(\"getPatchResultExtra, but intent is null\");\n        }\n        return ShareIntentUtil.getStringExtra(intent, RESULT_CLASS_EXTRA);\n    }\n","sourceCodeStart":74,"sourceCodeEnd":110,"githubUrl":"https://github.com/Tencent/tinker/blob/1b7ea02c239840f563ea64fb5bd286eb98d4011e/tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/service/TinkerPatchService.java#L74-L110","documentation":"TinkerPatchService.getPatchPathExtra is a static convenience accessor that reads the patch file path extra from the intent that started the patch service. It throws immediately when handed a null Intent rather than returning null. Callers are usually app code (or a custom AbstractPatch) reacting to the patch service's intent.","triggerScenarios":"Calling TinkerPatchService.getPatchPathExtra(intent) with a null Intent — e.g., in onHandleIntent of a restarted IntentService where the platform redelivers a null intent, or custom code that fetched the starting intent before it was set.","commonSituations":"Custom result/patch services that assume a non-null intent after process restart; defensive code paths receiving intent from getBindIntent-style helpers that can return null; porting tinker integration where the intent parameter is optional.","solutions":["Null-check the Intent before calling the helper.","In service callbacks, guard the whole body when intent == null instead of passing it through.","Use the standard TinkerInstaller.onReceiveUpgradePatch flow, which always supplies a populated intent."],"exampleFix":"// before\nString path = TinkerPatchService.getPatchPathExtra(intent);\n\n// after\nString path = intent != null ? TinkerPatchService.getPatchPathExtra(intent) : null;\nif (path == null) return;","handlingStrategy":"validation","validationCode":"if (intent == null) return; // service redelivered a null intent\nString patchPath = TinkerPatchService.getPatchPathExtra(intent);\nif (patchPath == null) return;","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Null-check intents at every service entry point before calling tinker's static accessors.","Use START_NOT_STICKY or handle null-intent redelivery in your service.","Route all patch flows through TinkerInstaller helpers so extras are always present."],"tags":["tinker","android","service","intent","null-check"],"backgroundTag":null,"analyzedSha":"1b7ea02c239840f563ea64fb5bd286eb98d4011e","analyzedAt":"2026-08-14T15:16:52.110Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}