chatwoot/chatwoot · error · Error
error
Error message
error
What it means
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.
Source
Thrown at app/javascript/dashboard/store/modules/teamMembers.js:43
export const actions = {
get: async ({ commit }, { teamId }) => {
commit(SET_TEAM_MEMBERS_UI_FLAG, { isFetching: true });
try {
const { data } = await TeamsAPI.getAgents({ teamId });
commit(ADD_AGENTS_TO_TEAM, { data, teamId });
} catch (error) {
throw new Error(error);
} finally {
commit(SET_TEAM_MEMBERS_UI_FLAG, { isFetching: false });
}
},
create: async ({ commit }, { agentsList, teamId }) => {
commit(SET_TEAM_MEMBERS_UI_FLAG, { isCreating: true });
try {
const { data } = await TeamsAPI.addAgents({ agentsList, teamId });
commit(ADD_AGENTS_TO_TEAM, { teamId, data });
} catch (error) {
throw new Error(error);
} finally {
commit(SET_TEAM_MEMBERS_UI_FLAG, { isCreating: false });
}
},
update: async ({ commit }, { agentsList, teamId }) => {
commit(SET_TEAM_MEMBERS_UI_FLAG, { isUpdating: true });
try {
const response = await TeamsAPI.updateAgents({
agentsList,
teamId,
});
commit(ADD_AGENTS_TO_TEAM, response);
} catch (error) {
throw new Error(error);
} finally {
commit(SET_TEAM_MEMBERS_UI_FLAG, { isUpdating: false });
}
},View on GitHub (pinned to ed230f9bc0)
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.
Example fix
// before
} catch (error) {
throw new Error(error);
} finally {
commit(SET_TEAM_MEMBERS_UI_FLAG, { isCreating: false });
}
// after
} catch (error) {
throw error;
} finally {
commit(SET_TEAM_MEMBERS_UI_FLAG, { isCreating: false });
} Defensive patterns
Strategy: try-catch
Validate before calling
const canAddAgents = (agentsList, teamId) =>
Array.isArray(agentsList) && agentsList.length > 0 && Boolean(teamId);
// dispatch only with a non-empty roster for an existing team
if (canAddAgents(this.selectedAgentIds, this.team.id)) {
await this.$store.dispatch('teamMembers/create', {
agentsList: this.selectedAgentIds,
teamId: this.team.id,
});
} Type guard
null
Try / catch
try {
await this.$store.dispatch('teamMembers/create', { agentsList, teamId });
} catch (error) {
const message = !error?.message || error.message === '[object Object]'
? 'Could not add agents to the team'
: error.message;
this.showAlert(message);
} Prevention
- 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
When it happens
Trigger: 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.
Common situations: Adding agents to a team that was just deleted by another admin; stale team settings page; expired session; invalid agent IDs after user deletion.
Related errors
AI-assisted analysis of chatwoot/chatwoot@ed230f9bc0 (2026-08-21).
Data as JSON: /api/errors/9cbf1f522c4ef94b.
Report an issue: GitHub.