Tencent/matrix · error · IllegalArgumentException

Can't be here without a job id

Error message

Can't be here without a job id

What it means

MatrixJobIntentService.getWorkEnqueuer() picks the right WorkEnqueuer implementation for a component. On Android API 26+ work must be submitted through JobScheduler, which requires a job id; if the caller reaches this path without one (hasJobId == false), the library throws IllegalArgumentException because a JobWorkEnqueuer cannot be created without a jobId.

Solutions

  1. Always pass a valid positive jobId (used as the JobScheduler job id) when calling enqueueWork on API 26+ devices.
  2. Verify the call chain does not route through a variant that strips the jobId parameter before reaching getWorkEnqueuer.
  3. Test on an API 26+ emulator/device, since CompatWorkEnqueuer is used below API 26 and masks the bug.

Example fix

// before
MatrixJobIntentService.enqueueWork(context, component, 0, work); // treated as no job id
// after
MatrixJobIntentService.enqueueWork(context, component, JOB_ID_LEAK_SERVICE /* >= 1 */, work);
Defensive patterns

Strategy: validation

Validate before calling

if (Build.VERSION.SDK_INT >= 26 && jobId <= 0) {
    throw new IllegalStateException("jobId required on API 26+");
}
MatrixJobIntentService.enqueueWork(context, component, jobId, work);

Try / catch

try {
    MatrixJobIntentService.enqueueWork(context, component, jobId, work);
} catch (IllegalArgumentException e) {
    Log.e(TAG, "missing/invalid jobId for API 26+ enqueue", e);
}

Prevention

When it happens

Trigger: On devices running Android 8.0 (API 26) or newer, a code path resolves a WorkEnqueuer for a component with hasJobId=false — i.e. enqueueWork (or an internal caller) was invoked without a valid jobId >= 0.

Common situations: Calling an enqueue/start overload that omits jobId on an API 26+ device; passing jobId <= 0 or an invalid sentinel so the id is treated as absent; device-dependent behavior where the bug only reproduces on Oreo+.

Understand the failure class

Background: "missing required argument" and "the following required arguments were not provided": what required-argument errors mean and how to fix them — this error's family across 20 libraries.

Related errors


AI-assisted analysis of Tencent/matrix@3b8293bd65 (2026-09-08). Data as JSON: /api/errors/84431d88cbdcedaf. Report an issue: GitHub.

Appendix: source

Thrown at matrix/matrix-android/matrix-resource-canary/matrix-resource-canary-android/src/main/java/com/tencent/matrix/resource/MatrixJobIntentService.java:548

    public static void enqueueWork(@NonNull Context context, @NonNull ComponentName component,
                                   int jobId, @NonNull Intent work) {
        if (work == null) {
            throw new IllegalArgumentException("work must not be null");
        }
        synchronized (sLock) {
            WorkEnqueuer we = getWorkEnqueuer(context, component, true, jobId);
            we.ensureJobId(jobId);
            we.enqueueWork(work);
        }
    }

    static WorkEnqueuer getWorkEnqueuer(Context context, ComponentName cn, boolean hasJobId,
                                        int jobId) {
        WorkEnqueuer we = sClassWorkEnqueuer.get(cn);
        if (we == null) {
            if (Build.VERSION.SDK_INT >= 26) {
                if (!hasJobId) {
                    throw new IllegalArgumentException("Can't be here without a job id");
                }
                we = new JobWorkEnqueuer(context, cn, jobId);
            } else {
                we = new CompatWorkEnqueuer(context, cn);
            }
            sClassWorkEnqueuer.put(cn, we);
        }
        return we;
    }

    /**
     * Called serially for each work dispatched to and processed by the service.  This
     * method is called on a background thread, so you can do long blocking operations
     * here.  Upon returning, that work will be considered complete and either the next
     * pending work dispatched here or the overall service destroyed now that it has
     * nothing else to do.
     *
     * <p>Be aware that when running as a job, you are limited by the maximum job execution

View on GitHub (pinned to 3b8293bd65)