{"record":{"id":"ae0c21c7c2d08d6b","repo":"Tencent/matrix","slug":"params-can-not-be-null","errorCode":null,"errorMessage":"---params can not be null!","messagePattern":"---params can not be null!","errorType":"exception","errorClass":"TaskInitException","httpStatus":null,"severity":"error","filePath":"matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/ApkTask.java","lineNumber":64,"sourceCode":"\n\n    public ApkTask(JobConfig config, Map<String, String> params) {\n        this.params = params;\n        this.config = config;\n        progressListeners = new LinkedList<>();\n    }\n\n    public int getType() {\n        return type;\n    }\n\n    public void init() throws TaskInitException {\n        if (config == null) {\n            throw new TaskInitException(TAG + \"---jobConfig can not be null!\");\n        }\n\n        if (params == null) {\n            throw new TaskInitException(TAG + \"---params can not be null!\");\n        }\n    }\n\n    public void addProgressListener(ApkTaskProgressListener listener) {\n        if (listener != null) {\n            progressListeners.add(listener);\n        }\n    }\n\n    public void removeProgressListener(ApkTaskProgressListener listener) {\n        if (listener != null) {\n            progressListeners.remove(listener);\n        }\n    }\n\n    protected void notifyProgress(int progress, String message) {\n        for (ApkTaskProgressListener listener : progressListeners) {\n            listener.getProgress(progress, message);","sourceCodeStart":46,"sourceCodeEnd":82,"githubUrl":"https://github.com/Tencent/matrix/blob/3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7/matrix/matrix-android/matrix-apk-canary/src/main/java/com/tencent/matrix/apk/model/task/ApkTask.java#L46-L82","documentation":"ApkTask.init() validates required inputs; besides the JobConfig, each task needs its params map. When the params field is null, init() throws TaskInitException with this message. Tasks receive per-run parameters (e.g. inputs, options) through this map, so running without it is treated as a configuration error.","triggerScenarios":"Executing an ApkTask whose setParams(...) (or equivalent) was never called before init()/execute(), or a custom task that overrides parameter injection and leaves the base field null.","commonSituations":"Hand-constructed tasks in tests or tooling scripts missing the params step; a refactor renaming the params setter so the old call no longer populates the field; job runner assembling tasks dynamically and skipping the params assignment for one task type.","solutions":["Call setParams(...) with a non-null map before init(); pass at least an empty map if the task takes no options.","Audit the job-assembly code so every registered task receives both config and params.","For custom tasks, make params a constructor argument to make nullability impossible.","Add a pre-run check in the job executor that asserts config and params are set for all tasks."],"exampleFix":"// before\nCountRTask task = new CountRTask();\ntask.setConfig(jobConfig);\ntask.init();\n// after\nCountRTask task = new CountRTask();\ntask.setConfig(jobConfig);\ntask.setParams(new HashMap<String, String>());\ntask.init();","handlingStrategy":"validation","validationCode":"if (task.getParams() == null) {\n    task.setParams(new HashMap<String, String>());\n}\ntask.init();","typeGuard":"boolean hasParams(ApkTask task) {\n    return task != null && task.getParams() != null;\n}","tryCatchPattern":"try {\n    task.init();\n} catch (TaskInitException e) {\n    if (e.getMessage() != null && e.getMessage().contains(\"params\")) {\n        MatrixLog.e(TAG, \"params not injected for task: %s\", task.getClass().getSimpleName());\n    }\n    throw e;\n}","preventionTips":["Call setParams(...) immediately after setConfig(...) for every task.","Pass an empty map rather than null when a task has no options.","Centralize task construction so config+params injection happens in one place.","Add a runner assertion that both fields are set before execute()."],"tags":["apk-canary","task-init","missing-params","validation"],"backgroundTag":"missing-required-config-field","analyzedSha":"3b8293bd65d47eeea7caf1f32a3a5d4d5eab60e7","analyzedAt":"2026-09-08T08:01:39.722Z","contentChangedAt":"2026-09-08T08:01:39.722Z","schemaVersion":2},"datasetVersion":"2026-09-16T04:17:20.429Z"}