Skip to content

Commit bf577c2

Browse files
talissoncostaclaude
andcommitted
fix(dependencies): send feature_states when creating the change request
Also show the API's message when creation is refused, instead of a generic one. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
1 parent a8ddfa2 commit bf577c2

2 files changed

Lines changed: 18 additions & 1 deletion

File tree

‎frontend/common/services/useChangeRequest.ts‎

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,6 +25,9 @@ export const changeRequestService = service
2525
...rest,
2626
// The modal hands back users and groups in one list.
2727
approvals: approvals.filter((approval) => !!approval.user),
28+
// Required by the API even where the changes live in change sets,
29+
// as the feature modal's own flow sends.
30+
feature_states: [],
2831
group_assignments: approvals.filter((approval) => !!approval.group),
2932
},
3033
method: 'POST',

‎frontend/web/components/modals/create-feature/tabs/FeatureDependenciesTab/hooks/useStagedPrerequisites.tsx‎

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,17 @@ export type StagedChange = {
2222

2323
export type StagingError = { message: string; prerequisiteId?: number }
2424

25+
// DRF answers with { detail } or { field: [messages] }.
26+
const describeApiError = (e: unknown): string | undefined => {
27+
const data = (e as { data?: Record<string, unknown> })?.data
28+
if (!data || typeof data !== 'object') return
29+
if (typeof data.detail === 'string') return data.detail
30+
const [field, messages] = Object.entries(data)[0] ?? []
31+
return field
32+
? `${field}: ${([] as unknown[]).concat(messages).join(' ')}`
33+
: undefined
34+
}
35+
2536
type UseStagedPrerequisitesArgs = {
2637
environmentId: string
2738
projectId: number
@@ -127,7 +138,10 @@ export const useStagedPrerequisites = ({
127138
setError(
128139
(e as StagingError)?.message
129140
? (e as StagingError)
130-
: { message: 'Could not create the change request.' },
141+
: {
142+
message:
143+
describeApiError(e) ?? 'Could not create the change request.',
144+
},
131145
)
132146
} finally {
133147
setIsSubmitting(false)

0 commit comments

Comments
 (0)