{"record":{"id":"3118f24df1f20b72","repo":"fatedier/frp","slug":"apply-config-failed-failed-to-apply-config-v","errorCode":null,"errorMessage":"apply config failed: failed to apply config: %v","messagePattern":"apply config failed: failed to apply config: (.+?)","errorType":"http","errorClass":"configmgmt.ErrApplyConfig","httpStatus":500,"severity":"error","filePath":"client/config_manager.go","lineNumber":385,"sourceCode":"}\n\nfunc (m *serviceConfigManager) withStoreMutationAndReload(\n\tfn func(storeSource *source.StoreSource) error,\n) error {\n\tm.svr.reloadMu.Lock()\n\tdefer m.svr.reloadMu.Unlock()\n\n\tstoreSource := m.svr.storeSource\n\tif storeSource == nil {\n\t\treturn fmt.Errorf(\"%w: store API is disabled\", configmgmt.ErrStoreDisabled)\n\t}\n\n\tif err := fn(storeSource); err != nil {\n\t\treturn err\n\t}\n\n\tif err := m.svr.reloadConfigFromSourcesLocked(); err != nil {\n\t\treturn fmt.Errorf(\"%w: failed to apply config: %v\", configmgmt.ErrApplyConfig, err)\n\t}\n\treturn nil\n}\n\nfunc (m *serviceConfigManager) withStoreProxyMutationAndReload(\n\tname string,\n\tfn func(storeSource *source.StoreSource) error,\n) (v1.ProxyConfigurer, error) {\n\tm.svr.reloadMu.Lock()\n\tdefer m.svr.reloadMu.Unlock()\n\n\tstoreSource := m.svr.storeSource\n\tif storeSource == nil {\n\t\treturn nil, fmt.Errorf(\"%w: store API is disabled\", configmgmt.ErrStoreDisabled)\n\t}\n\n\tif err := fn(storeSource); err != nil {\n\t\treturn nil, err","sourceCodeStart":367,"sourceCodeEnd":403,"githubUrl":"https://github.com/fatedier/frp/blob/6c8a8d0a97d03b44e9528d30b30c70cb9d61b405/client/config_manager.go#L367-L403","documentation":"After a store mutation succeeds, withStoreMutationAndReload calls reloadConfigFromSourcesLocked to apply the new combined config (file source + store source) to the running client. If that reload fails, the mutation is kept in the store but is not running, and the error is wrapped with configmgmt.ErrApplyConfig. Reload failures come from validation/initialization of the aggregated config.","triggerScenarios":"Create/update/delete via store API where re-validating all proxies/visitors (file + store) fails after the write — e.g. duplicate proxy names between file config and store, or a combined config that no longer passes client validation.","commonSituations":"A proxy in frpc.toml and a store-created proxy collide on name or bind port; partial upgrade where an old config becomes invalid under stricter new-version validation; the mutation itself succeeded so the store and running state have diverged until the next successful reload.","solutions":["Inspect the wrapped %v to see which config entry failed re-validation","Resolve the conflict (rename the colliding proxy or change bindPort) — check both frpc.toml and the store contents","Call GET /api/reload after fixing; the store keeps your mutation, so a successful reload brings it live","Avoid defining the same proxy both in the config file and through the store API"],"exampleFix":null,"handlingStrategy":"try-catch","validationCode":null,"typeGuard":null,"tryCatchPattern":"if resp.StatusCode == http.StatusInternalServerError {\n\t// store mutated but reload failed: read detail, fix conflict, then GET /api/reload\n}","preventionTips":["Never define the same proxy name in both the config file and the store","After any 5xx from a mutation, call GET /api/reload once the conflict is fixed to re-sync runtime"],"tags":["frp","frpc","config-store","reload","apply"],"backgroundTag":null,"analyzedSha":"6c8a8d0a97d03b44e9528d30b30c70cb9d61b405","analyzedAt":"2026-08-15T06:53:27.215Z","schemaVersion":2},"datasetVersion":"2026-08-15T22:17:37.221Z"}