{"record":{"id":"9cbf1f522c4ef94b","repo":"chatwoot/chatwoot","slug":"error-9cbf1f","errorCode":null,"errorMessage":"error","messagePattern":"error","errorType":"exception","errorClass":"Error","httpStatus":null,"severity":"error","filePath":"app/javascript/dashboard/store/modules/teamMembers.js","lineNumber":43,"sourceCode":"export const actions = {\n  get: async ({ commit }, { teamId }) => {\n    commit(SET_TEAM_MEMBERS_UI_FLAG, { isFetching: true });\n    try {\n      const { data } = await TeamsAPI.getAgents({ teamId });\n      commit(ADD_AGENTS_TO_TEAM, { data, teamId });\n    } catch (error) {\n      throw new Error(error);\n    } finally {\n      commit(SET_TEAM_MEMBERS_UI_FLAG, { isFetching: false });\n    }\n  },\n  create: async ({ commit }, { agentsList, teamId }) => {\n    commit(SET_TEAM_MEMBERS_UI_FLAG, { isCreating: true });\n    try {\n      const { data } = await TeamsAPI.addAgents({ agentsList, teamId });\n      commit(ADD_AGENTS_TO_TEAM, { teamId, data });\n    } catch (error) {\n      throw new Error(error);\n    } finally {\n      commit(SET_TEAM_MEMBERS_UI_FLAG, { isCreating: false });\n    }\n  },\n  update: async ({ commit }, { agentsList, teamId }) => {\n    commit(SET_TEAM_MEMBERS_UI_FLAG, { isUpdating: true });\n    try {\n      const response = await TeamsAPI.updateAgents({\n        agentsList,\n        teamId,\n      });\n      commit(ADD_AGENTS_TO_TEAM, response);\n    } catch (error) {\n      throw new Error(error);\n    } finally {\n      commit(SET_TEAM_MEMBERS_UI_FLAG, { isUpdating: false });\n    }\n  },","sourceCodeStart":25,"sourceCodeEnd":61,"githubUrl":"https://github.com/chatwoot/chatwoot/blob/ed230f9bc068e7a13dd5c0404d5465a204b68d4c/app/javascript/dashboard/store/modules/teamMembers.js#L25-L61","documentation":"In the `create` action of the teamMembers store, a failed `TeamsAPI.addAgents({ agentsList, teamId })` is re-wrapped as `throw new Error(error)`. The catch sits between the isCreating flag set and its finally reset; the wrap stringifies the error object ('[object Object]' for plain objects, one flattened line for axios errors) and discards the response, status and stack. The identical `get` action above has the same defect.","triggerScenarios":"Dispatching `teamMembers/create` (adding agents to a team) when the add-agents request returns 404 (team deleted in another session), 422 (invalid/empty agentsList), 401 (expired token), or fails at network level.","commonSituations":"Adding agents to a team that was just deleted by another admin; stale team settings page; expired session; invalid agent IDs after user deletion.","solutions":["Rethrow the original: `throw error;` (do the same in the `get` action above, which has the identical wrap).","Or extract with fallbacks: `throw new Error(error?.response?.data?.message || error?.message || 'Could not add agents');`","Catch the dispatch in the team members UI and show the message next to the agent picker.","Add a failure-path spec stubbing TeamsAPI.addAgents to reject."],"exampleFix":"// before\n} catch (error) {\n  throw new Error(error);\n} finally {\n  commit(SET_TEAM_MEMBERS_UI_FLAG, { isCreating: false });\n}\n\n// after\n} catch (error) {\n  throw error;\n} finally {\n  commit(SET_TEAM_MEMBERS_UI_FLAG, { isCreating: false });\n}","handlingStrategy":"try-catch","validationCode":"const canAddAgents = (agentsList, teamId) =>\n  Array.isArray(agentsList) && agentsList.length > 0 && Boolean(teamId);\n// dispatch only with a non-empty roster for an existing team\nif (canAddAgents(this.selectedAgentIds, this.team.id)) {\n  await this.$store.dispatch('teamMembers/create', {\n    agentsList: this.selectedAgentIds,\n    teamId: this.team.id,\n  });\n}","typeGuard":"null","tryCatchPattern":"try {\n  await this.$store.dispatch('teamMembers/create', { agentsList, teamId });\n} catch (error) {\n  const message = !error?.message || error.message === '[object Object]'\n    ? 'Could not add agents to the team'\n    : error.message;\n  this.showAlert(message);\n}","preventionTips":["Patch the store (and the identical `get` action) to `throw error;`","Require a non-empty agentsList in the UI before submit","Refetch the team before editing to catch concurrent deletes","Add failure-path specs"],"tags":["vuex","axios","chatwoot","teams","error-handling"],"backgroundTag":"object-object-error-message","analyzedSha":"ed230f9bc068e7a13dd5c0404d5465a204b68d4c","analyzedAt":"2026-08-21T12:45:25.920Z","schemaVersion":2},"datasetVersion":"2026-08-21T13:17:26.733Z"}