{"record":{"id":"33b51766d2bf24f8","repo":"apolloconfig/apollo","slug":"config-can-not-be-published-by-yourself","errorCode":null,"errorMessage":"Config can not be published by yourself.","messagePattern":"Config can not be published by yourself\\.","errorType":"exception","errorClass":"BadRequestException","httpStatus":400,"severity":"warning","filePath":"apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java","lineNumber":279,"sourceCode":"    checkLock(namespace, isEmergencyPublish, operator);\n\n    Map<String, String> operateNamespaceItems = getNamespaceItems(namespace);\n\n    Namespace parentNamespace = namespaceService.findParentNamespace(namespace);\n\n    // branch release\n    if (parentNamespace != null) {\n      return publishBranchNamespace(parentNamespace, namespace, operateNamespaceItems, releaseName,\n          releaseComment, operator, isEmergencyPublish, grayDelKeys);\n    }\n    throw new NotFoundException(\"Parent namespace not found\");\n  }\n\n  private void checkLock(Namespace namespace, boolean isEmergencyPublish, String operator) {\n    if (!isEmergencyPublish) {\n      NamespaceLock lock = namespaceLockService.findLock(namespace.getId());\n      if (lock != null && lock.getDataChangeCreatedBy().equals(operator)) {\n        throw new BadRequestException(\"Config can not be published by yourself.\");\n      }\n    }\n  }\n\n  private void mergeFromMasterAndPublishBranch(Namespace parentNamespace, Namespace childNamespace,\n      Map<String, String> parentNamespaceItems, String releaseName, String releaseComment,\n      String operator, Release masterPreviousRelease, Release parentRelease,\n      boolean isEmergencyPublish) {\n    // create release for child namespace\n    Release childNamespaceLatestActiveRelease = findLatestActiveRelease(childNamespace);\n\n    Map<String, String> childReleaseConfiguration;\n    Collection<String> branchReleaseKeys;\n    if (childNamespaceLatestActiveRelease != null) {\n      childReleaseConfiguration =\n          GSON.fromJson(childNamespaceLatestActiveRelease.getConfigurations(), GsonType.CONFIG);\n      branchReleaseKeys = getBranchReleaseKeys(childNamespaceLatestActiveRelease.getId());\n    } else {","sourceCodeStart":261,"sourceCodeEnd":297,"githubUrl":"https://github.com/apolloconfig/apollo/blob/d95fc18d112589efc09ddcbe1507047584d55251/apollo-biz/src/main/java/com/ctrip/framework/apollo/biz/service/ReleaseService.java#L261-L297","documentation":"Thrown as BadRequestException (HTTP 400) by ReleaseService.checkLock during a non-emergency publish when a NamespaceLock exists and its creator equals the current operator. Apollo prevents the user who locked a namespace from also publishing it, to enforce separation of duties (the locker must not also be the publisher).","triggerScenarios":"The same user who created/acquired the NamespaceLock attempts a normal publish of that namespace (isEmergencyPublish=false).","commonSituations":"Single-developer namespaces where the same person locks and publishes; service accounts used for both edit and publish; forgotten lock left by the current operator.","solutions":["Have a different user (who did not create the lock) perform the publish.","Release/clear the NamespaceLock first, then publish.","If separation of duties does not apply, use emergency publish (isEmergencyPublish=true) which bypasses the check."],"exampleFix":"// before: same user locked then publishes -> 400 'Config can not be published by yourself.'\n// after: clear the lock, then publish\nnamespaceLockService.unlock(namespaceId, operator);\nreleaseService.publish(...); // or pass isEmergencyPublish=true","handlingStrategy":"validation","validationCode":"NamespaceLock lock = namespaceLockService.findLock(namespace.getId());\nboolean lockOwnerIsOperator = lock != null && lock.getDataChangeCreatedBy().equals(operator);\nif (lockOwnerIsOperator && !isEmergencyPublish) {\n  // have another user publish, clear the lock, or use emergency publish\n}","typeGuard":null,"tryCatchPattern":"try {\n  releaseService.publish(appId, env, cluster, ns, name, comment, operator, false, null);\n} catch (BadRequestException e) {\n  if (e.getMessage().contains(\"published by yourself\")) {\n    // escalate to a different operator or use isEmergencyPublish=true\n  } else throw e;\n}","preventionTips":["Use distinct service accounts for edit vs publish workflows.","Clear stale locks before publishing.","Reserve emergency publish for genuine incidents."],"tags":["release","publish","lock","permissions","bad-request","apollo-biz"],"backgroundTag":null,"analyzedSha":"d95fc18d112589efc09ddcbe1507047584d55251","analyzedAt":"2026-08-14T04:00:05.477Z","schemaVersion":2},"datasetVersion":"2026-08-14T05:17:29.042Z"}