{"record":{"id":"32f3d0cbd7f8ad96","repo":"alibaba/Sentinel","slug":"the-sentinel-default-context-can-t-be-permit-to-de","errorCode":null,"errorMessage":"The sentinel_default_context can't be permit to defined!","messagePattern":"The sentinel_default_context can't be permit to defined!","errorType":"validation","errorClass":"ContextNameDefineException","httpStatus":null,"severity":"error","filePath":"sentinel-core/src/main/java/com/alibaba/csp/sentinel/context/ContextUtil.java","lineNumber":114,"sourceCode":"     * The origin node will be created in {@link com.alibaba.csp.sentinel.slots.clusterbuilder.ClusterBuilderSlot}.\n     * Note that each distinct {@code origin} of different resources will lead to creating different new\n     * {@link Node}, meaning that total amount of created origin statistic nodes will be:<br/>\n     * {@code distinct resource name amount * distinct origin count}.<br/>\n     * So when there are too many origins, memory footprint should be carefully considered.\n     * </p>\n     * <p>\n     * Same resource in different context will count separately, see {@link NodeSelectorSlot}.\n     * </p>\n     *\n     * @param name   the context name\n     * @param origin the origin of this invocation, usually the origin could be the Service\n     *               Consumer's app name. The origin is useful when we want to control different\n     *               invoker/consumer separately.\n     * @return The invocation context of the current thread\n     */\n    public static Context enter(String name, String origin) {\n        if (Constants.CONTEXT_DEFAULT_NAME.equals(name)) {\n            throw new ContextNameDefineException(\n                \"The \" + Constants.CONTEXT_DEFAULT_NAME + \" can't be permit to defined!\");\n        }\n        return trueEnter(name, origin);\n    }\n\n    protected static Context trueEnter(String name, String origin) {\n        Context context = contextHolder.get();\n        if (context == null) {\n            Map<String, DefaultNode> localCacheNameMap = contextNameNodeMap;\n            DefaultNode node = localCacheNameMap.get(name);\n            if (node == null) {\n                if (localCacheNameMap.size() > Constants.MAX_CONTEXT_NAME_SIZE) {\n                    setNullContext();\n                    return NULL_CONTEXT;\n                } else {\n                    LOCK.lock();\n                    try {\n                        node = contextNameNodeMap.get(name);","sourceCodeStart":96,"sourceCodeEnd":132,"githubUrl":"https://github.com/alibaba/Sentinel/blob/a3f40ba8e900c8489bd520274739f17235a7721c/sentinel-core/src/main/java/com/alibaba/csp/sentinel/context/ContextUtil.java#L96-L132","documentation":"ContextUtil.enter(name, origin) explicitly forbids using Sentinel's reserved default context name 'sentinel_default_context' as a custom context: doing so throws ContextNameDefineException. The default context is created internally by ContextUtil.internalEnter for users who never call enter(); letting callers register it manually would collide with that internal bookkeeping.","triggerScenarios":"Calling ContextUtil.enter(\"sentinel_default_context\", origin) or Constants.CONTEXT_DEFAULT_NAME directly; deriving context names from config/user input that happens to equal the reserved constant.","commonSituations":"Hardcoding a context name without knowing the reserved value; echoing the name seen in Sentinel dashboard/log (which shows sentinel_default_context when no context is set) back into enter(); property-driven context naming in multi-tenant gateways.","solutions":["Use a distinct, meaningful context name, e.g. ContextUtil.enter(\"myServiceContext\", origin)","If the context name comes from external input, blacklist Constants.CONTEXT_DEFAULT_NAME before calling enter","If you actually want the default behavior, simply omit ContextUtil.enter — Sentinel uses the default context automatically"],"exampleFix":"// before\nContextUtil.enter(\"sentinel_default_context\", \"consumerA\");\n\n// after\nContextUtil.enter(\"orderServiceContext\", \"consumerA\");","handlingStrategy":"validation","validationCode":"String safeName = Constants.CONTEXT_DEFAULT_NAME.equals(name) ? \"appContext\" : name;\nContextUtil.enter(safeName, origin);","typeGuard":null,"tryCatchPattern":null,"preventionTips":["Use descriptive context names unique to your call path; never copy names seen in the dashboard back into code","Blacklist the reserved default context constant when context names come from external configuration"],"tags":["core","context","reserved-name","configuration","illegal-argument"],"backgroundTag":null,"analyzedSha":"a3f40ba8e900c8489bd520274739f17235a7721c","analyzedAt":"2026-08-14T11:10:30.678Z","schemaVersion":2},"datasetVersion":"2026-08-15T17:31:12.345Z"}