{"record":{"id":"52f12cdbe030c227","repo":"Tencent/QMUI_Android","slug":"requestcode-can-not-be-s","errorCode":null,"errorMessage":"requestCode can not be %s","messagePattern":"requestCode can not be (.+?)","errorType":"validation","errorClass":"RuntimeException","httpStatus":null,"severity":"error","filePath":"arch/src/main/java/com/qmuiteam/qmui/arch/QMUIFragment.java","lineNumber":495,"sourceCode":"\n    /**\n     * simulate the behavior of startActivityForResult/onActivityResult:\n     * 1. Jump fragment1 to fragment2 via startActivityForResult(fragment2, requestCode)\n     * 2. Pass data from fragment2 to fragment1 via setFragmentResult(RESULT_OK, data)\n     * 3. Get data in fragment1 through onFragmentResult(requestCode, resultCode, data)\n     *\n     * @deprecated use {@link #registerEffect} for a replacement\n     *\n     * @param fragment    target fragment\n     * @param requestCode request code\n     */\n    @Deprecated\n    public int startFragmentForResult(QMUIFragment fragment, int requestCode) {\n        if (!checkStateLoss(\"startFragmentForResult\")) {\n            return -1;\n        }\n        if (requestCode == NO_REQUEST_CODE) {\n            throw new RuntimeException(\"requestCode can not be \" + NO_REQUEST_CODE);\n        }\n        QMUIFragmentContainerProvider provider = findFragmentContainerProvider(true);\n        if (provider == null) {\n            if (QMUIConfig.DEBUG) {\n                throw new RuntimeException(\"Can not find the fragment container provider.\");\n            } else {\n                Log.d(TAG, \"Can not find the fragment container provider.\");\n                return -1;\n            }\n        }\n\n        mSourceRequestCode = requestCode;\n        fragment.mTargetFragmentUUid = mUUid;\n        fragment.mTargetRequestCode = requestCode;\n        return startFragment(fragment, provider);\n    }\n\n    private int startFragment(QMUIFragment fragment, QMUIFragmentContainerProvider provider) {","sourceCodeStart":477,"sourceCodeEnd":513,"githubUrl":"https://github.com/Tencent/QMUI_Android/blob/026e7d486677d6593a96689cd590ec3561176717/arch/src/main/java/com/qmuiteam/qmui/arch/QMUIFragment.java#L477-L513","documentation":"Thrown by a generic input guard at the top of the deprecated startFragmentForResult method: before launching the target fragment, the method validates its requestCode argument against the NO_REQUEST_CODE sentinel constant and throws a RuntimeException if they are equal. NO_REQUEST_CODE is the internal marker reserved for fragments that were NOT started for a result, so a caller passing it would make the later onFragmentResult dispatch impossible to route back. The error therefore means the caller invoked startFragmentForResult with the reserved sentinel value (typically the default/uninitialized requestCode) instead of a unique caller-defined request code, and the faulting input is the requestCode parameter.","triggerScenarios":"Calling the deprecated startFragmentForResult(fragment, requestCode) with requestCode equal to NO_REQUEST_CODE (the library's reserved sentinel, typically -1).","commonSituations":"Passing -1 as a 'default' requestCode; copying code from startFragment and reusing sentinel constants; calling the deprecated overload instead of the newer API.","solutions":["Use a positive requestCode (e.g. 1, 2, ...) distinct from NO_REQUEST_CODE","Migrate off the deprecated overload to the current startFragmentForResult API","Define app constants for request codes to avoid accidental sentinel usage"],"exampleFix":"// before\nstartFragmentForResult(fragment, -1);\n// after\nstartFragmentForResult(fragment, 1001);","handlingStrategy":"validation","validationCode":"if (requestCode != QMUIFragment.NO_REQUEST_CODE) { startFragmentForResult(fragment, requestCode); }","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use positive constants for request codes","Never pass -1 or library sentinel values","Migrate off deprecated startFragmentForResult overloads"],"tags":["android","request-code","deprecated"],"backgroundTag":"invalid-argument-value","analyzedSha":"026e7d486677d6593a96689cd590ec3561176717","analyzedAt":"2026-09-06T13:32:24.816Z","contentChangedAt":"2026-09-06T13:32:24.816Z","schemaVersion":2},"datasetVersion":"2026-09-14T00:17:10.932Z"}