Tencent/tinker · error · TinkerRuntimeException

getPatchResultExtra, but intent is null

Error message

getPatchResultExtra, but intent is null

What it means

TinkerPatchService.getPatchResultExtra reads the result-service class name extra from the starting intent so the patch flow knows where to dispatch the final PatchResult. It throws on a null Intent, mirroring the other static accessors in this class.

Source

Thrown at tinker-android/tinker-android-lib/src/main/java/com/tencent/tinker/lib/service/TinkerPatchService.java:106

    }

    public static String getPatchPathExtra(Intent intent) {
        if (intent == null) {
            throw new TinkerRuntimeException("getPatchPathExtra, but intent is null");
        }
        return ShareIntentUtil.getStringExtra(intent, PATCH_PATH_EXTRA);
    }

    public static boolean getPatchUseEmergencyMode(Intent intent) {
        if (intent == null) {
            throw new TinkerRuntimeException("getPatchUseEmergencyMode, but intent is null");
        }
        return ShareIntentUtil.getBooleanExtra(intent, PATCH_USE_EMERGENCY_MODE, false);
    }

    public static String getPatchResultExtra(Intent intent) {
        if (intent == null) {
            throw new TinkerRuntimeException("getPatchResultExtra, but intent is null");
        }
        return ShareIntentUtil.getStringExtra(intent, RESULT_CLASS_EXTRA);
    }

    @Override
    protected void onHandleIntent(Intent intent) {
        increasingPriority();
        doApplyPatch(this, intent);
    }

    /**
     * set the tinker notification id you want
     * @param id
     */
    public static void setTinkerNotificationId(int id) {
        notificationId = id;
    }

View on GitHub (pinned to 1b7ea02c23)

Solutions

  1. Short-circuit null intents at the service entry point before calling any get*Extra helper.
  2. Start the patch service only via the provided TinkerPatchService.runPatchService / TinkerInstaller APIs that populate all extras.
  3. In tests, construct the Intent with the required extras rather than passing null.

Example fix

// before
String resultClass = TinkerPatchService.getPatchResultExtra(intent);

// after
if (intent == null) return;
String resultClass = TinkerPatchService.getPatchResultExtra(intent);
Defensive patterns

Strategy: validation

Validate before calling

if (intent == null) return;
String resultClass = TinkerPatchService.getPatchResultExtra(intent);

Prevention

When it happens

Trigger: Calling getPatchResultExtra(intent) with a null Intent — for instance in a custom onHandleIntent or a subclass of TinkerPatchService that does not short-circuit null intents before delegating.

Common situations: System redelivery of a null intent to a sticky IntentService; custom patch service subclasses; unit tests constructing null intents to exercise patch logic.

Related errors


AI-assisted analysis of Tencent/tinker@1b7ea02c23 (2026-08-14). Data as JSON: /api/errors/65521742d739d8de. Report an issue: GitHub.