Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
12 changes: 9 additions & 3 deletions src/actions/sponsor-forms-actions.js
Original file line number Diff line number Diff line change
Expand Up @@ -174,7 +174,8 @@ export const getSponsorForm = (formId) => async (dispatch, getState) => {
dispatch(startLoading());

const params = {
access_token: accessToken
access_token: accessToken,
expand: "meta_fields,meta_fields.values,sponsorship_types"
};

return getRequest(
Expand Down Expand Up @@ -507,6 +508,7 @@ export const getSponsorManagedForms =
page,
fields:
"id,code,name,is_archived,opens_at,expires_at,items_count,allowed_add_ons",
expands: "allowed_add_ons",
per_page: perPage,
Comment on lines +511 to 512

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

🧩 Analysis chain

🏁 Script executed:

#!/bin/bash
set -euo pipefail

echo "1) Inspect usage patterns of expand/expands in actions:"
rg -n --type=js '\bexpand[s]?\s*:' src/actions

echo
echo "2) Check for API docs/spec references in repo mentioning expand vs expands:"
fd -i 'openapi|swagger|api' | xargs -r rg -n '"expand"|"expands"|[?&]expand=|[?&]expands='

echo
echo "Expected: one canonical query key across purchases endpoints (preferably 'expand')."

Repository: fntechgit/summit-admin

Length of output: 11891


🏁 Script executed:

# Extract context around the expands usage lines in sponsor-forms-actions.js
echo "=== Context around line 511 ==="
sed -n '505,520p' src/actions/sponsor-forms-actions.js

echo
echo "=== Context around line 617 ==="
sed -n '610,625p' src/actions/sponsor-forms-actions.js

echo
echo "=== Context around line 1015 ==="
sed -n '1010,1025p' src/actions/sponsor-forms-actions.js

echo
echo "=== Context around line 1419 ==="
sed -n '1413,1430p' src/actions/sponsor-forms-actions.js

echo
echo "=== Check for any API spec or documentation files ==="
find . -type f \( -name "*.md" -o -name "*.txt" -o -name "*.json" \) | xargs grep -l "expand" 2>/dev/null | head -10

Repository: fntechgit/summit-admin

Length of output: 2415


🏁 Script executed:

# Search for any comments or documentation about expand parameters
echo "=== Search for comments mentioning expand/expands ==="
rg -n -B2 -A2 "expand" src/actions/sponsor-forms-actions.js | head -50

echo
echo "=== Check the getRequest function to understand parameter handling ==="
rg -n "const getRequest|function getRequest" src/

echo
echo "=== Look at similar API calls with expand in the same file ==="
grep -n "expand:" src/actions/sponsor-forms-actions.js

Repository: fntechgit/summit-admin

Length of output: 1682


🏁 Script executed:

# Search for getRequest function definition and any parameter handling
echo "=== Find getRequest definition ==="
rg -n "const getRequest|function getRequest|export.*getRequest" src/ | head -20

echo
echo "=== Check if there's any middleware or utility that might transform expands to expand ==="
find src -name "*util*" -o -name "*helper*" -o -name "*middleware*" | xargs ls -la 2>/dev/null

echo
echo "=== Look for api-related utilities ==="
fd -type f "api|request" src/ | head -20

Repository: fntechgit/summit-admin

Length of output: 2349


🏁 Script executed:

# Search for getRequest imports
echo "=== Search for getRequest imports in sponsor-forms-actions.js ==="
head -50 src/actions/sponsor-forms-actions.js | grep -n "getRequest\|import"

echo
echo "=== Search for getRequest in utils/methods ==="
grep -n "getRequest" src/utils/methods.js | head -5

echo
echo "=== Look at the actual method signature and parameter handling ==="
rg -A 20 "export.*getRequest" src/utils/methods.js | head -40

Repository: fntechgit/summit-admin

Length of output: 470


🏁 Script executed:

# Search more broadly for getRequest definition
echo "=== Search entire src directory for getRequest definition ==="
rg -n "getRequest\s*=" src/ | head -20

echo
echo "=== Search in node_modules or other locations ==="
rg -n "function getRequest|const getRequest =" . --max-depth 3 2>/dev/null | grep -v node_modules | head -10

echo
echo "=== Check if getRequest is from an external library (look at package.json) ==="
grep -n "redux\|api\|axios\|fetch" package.json | head -20

Repository: fntechgit/summit-admin

Length of output: 425


🏁 Script executed:

# Check the full imports from utils/methods.js
echo "=== Check imports in sponsor-forms-actions.js ==="
sed -n '14,25p' src/actions/sponsor-forms-actions.js

echo
echo "=== Look for getRequest in utils/methods.js ==="
head -100 src/utils/methods.js | grep -n "getRequest\|export"

echo
echo "=== Check the entire utils/methods.js file size and search for getRequest ==="
wc -l src/utils/methods.js
rg -n "getRequest" src/utils/methods.js

Repository: fntechgit/summit-admin

Length of output: 805


🏁 Script executed:

# getRequest is from external library, let's check if there's any API documentation
echo "=== Check for any API docs or comments about parameters ==="
find src -type f \( -name "*.md" -o -name "*.txt" \) | xargs cat 2>/dev/null

echo
echo "=== Check the API calls in sponsor-forms-actions.js for patterns ==="
echo "Looking at the similar API calls..."
grep -B5 "expand\|expands" src/actions/sponsor-forms-actions.js | grep -E "PURCHASES_API_URL|/api/" 

echo
echo "=== Check what endpoints these calls hit ==="
rg -B10 "expands:" src/actions/sponsor-forms-actions.js | grep -E "PURCHASES_API_URL|/api/"

Repository: fntechgit/summit-admin

Length of output: 277


🏁 Script executed:

# Let me look at the full context of the API calls with expands
echo "=== Get full context around expands calls ==="
sed -n '505,530p' src/actions/sponsor-forms-actions.js

echo
echo "=== Get full context around line 659 (similar call with expand) ==="
sed -n '650,675p' src/actions/sponsor-forms-actions.js

echo
echo "=== Check if there are any tests or documentation that might clarify ==="
find . -path ./node_modules -prune -o -name "*.test.js" -type f -print | xargs grep -l "sponsor.*form\|expands" 2>/dev/null | head -5

Repository: fntechgit/summit-admin

Length of output: 2031


🏁 Script executed:

# Check the test file for sponsor-forms-actions
echo "=== Check sponsor-forms-actions test file for any clues ==="
cat src/actions/__tests__/sponsor-forms-actions.test.js

Repository: fntechgit/summit-admin

Length of output: 6356


🏁 Script executed:

# Let me check if there's any comment in the file explaining the expands usage
echo "=== Search for any comments around expands in the file ==="
grep -B10 -A5 "expands:" src/actions/sponsor-forms-actions.js | head -80

echo
echo "=== Check if there's a pattern - do expands calls work differently? ==="
echo "Checking function names where expands is used:"
rg -B20 "expands:" src/actions/sponsor-forms-actions.js | grep "export const\|const.*=.*=>.*(" | head -10

echo
echo "=== Check for any recent git history or comments ==="
git log --oneline -n 20 2>/dev/null || echo "Git history not available"

Repository: fntechgit/summit-admin

Length of output: 2172


🏁 Script executed:

# Check the git commit that added expands
echo "=== Check the commit that added expands ==="
git show b7ee000 --stat 2>/dev/null || echo "Cannot show commit details"

echo
echo "=== Check if there are other commits mentioning expands ==="
git log --all --oneline --grep="expands" 2>/dev/null || echo "Git grep not available"

echo
echo "=== Check sponsor-forms-actions.js git blame for these lines ==="
git blame -L511,512 src/actions/sponsor-forms-actions.js 2>/dev/null || echo "Git blame not available"

echo
echo "=== Alternative: search for any API documentation or changelog ==="
find . -path ./node_modules -prune -o -name "CHANGELOG*" -o -name "API*" -type f -print 2>/dev/null

Repository: fntechgit/summit-admin

Length of output: 50378


🏁 Script executed:

# Check if there are any tests or mocks that show API response structures
echo "=== Look for any mocked API responses related to sponsor forms ==="
find . -path ./node_modules -prune -o -name "*.mock*" -o -name "*.json" -type f -print | xargs grep -l "sponsor.*form\|expand" 2>/dev/null | head -5

echo
echo "=== Check the actual reducer to see if it processes the expanded data ==="
rg -n "sponsor.*form" src/reducers/ | head -10

Repository: fntechgit/summit-admin

Length of output: 1441


🏁 Script executed:

# Check if the reducer actually uses the expanded fields
echo "=== Check sponsor-form-items-list-reducer to see if it uses expanded data ==="
cat src/reducers/sponsors/sponsor-form-items-list-reducer.js

echo
echo "=== Look for any error handling or validation related to expand parameter ==="
rg -n "expand\|expands" src/reducers/sponsors/ | head -20

Repository: fntechgit/summit-admin

Length of output: 4005


🏁 Script executed:

# Let's verify if there's any documentation about the parameter name in the codebase
echo "=== Search for any comments or documentation about the PURCHASES_API ==="
rg -n "PURCHASES_API" src/actions/sponsor-forms-actions.js | head -5

echo
echo "=== Check if the commit author left any other clues ==="
git log --all --oneline --author="Castillo" 2>/dev/null | head -10

echo
echo "=== Let's check if line 659 call (with expand) is for similar endpoint ==="
sed -n '650,675p' src/actions/sponsor-forms-actions.js

Repository: fntechgit/summit-admin

Length of output: 2230


🏁 Script executed:

# Let's check what the API actually returns and if these expanded fields are present
echo "=== Check the test file to see what response structure is expected ==="
grep -A 30 "RECEIVE_SPONSOR_FORM_ITEM\|RECEIVE_SPONSOR_FORM_ITEMS" src/actions/__tests__/sponsor-forms-actions.test.js | head -50

echo
echo "=== Look at what fields are actually used from the response in the reducer ==="
rg -A 10 "RECEIVE_SPONSOR_FORM_ITEM" src/reducers/sponsors/sponsor-form-items-list-reducer.js

echo
echo "=== Check if there's a pattern - compare similar calls in the file ==="
echo "Functions using expands:"
rg -B 20 "expands:" src/actions/sponsor-forms-actions.js | grep "^[0-9]*-export const" | head -10

echo
echo "Functions using expand:"
rg -B 20 "expand:" src/actions/sponsor-forms-actions.js | grep "^[0-9]*-export const" | head -10

Repository: fntechgit/summit-admin

Length of output: 1265


🏁 Script executed:

# Final verification: check if there's any API documentation or README that mentions parameter names
echo "=== Search for README or documentation files ==="
find . -path ./node_modules -prune -o -name "README*" -o -name "*.md" -type f -print 2>/dev/null | xargs cat 2>/dev/null | grep -i "expand" | head -20

echo
echo "=== Check the structure more carefully - show exact lines with context for expands vs expand ==="
echo "=== All instances of expand/expands in sponsor-forms-actions.js ==="
grep -n "expand" src/actions/sponsor-forms-actions.js

Repository: fntechgit/summit-admin

Length of output: 637


Change expands to expand for API consistency.

Four API calls in this file use expands while the codebase standard (100+ instances across action files) and the OpenStack API expect expand (singular). Using the unsupported parameter name will cause the API to silently ignore these expansion requests, leaving related fields incomplete in responses. Lines 511, 617, 1015, and 1419 require correction.

Proposed fix
-      expands: "allowed_add_ons",
+      expand: "allowed_add_ons",
@@
-      expands: "allowed_add_ons",
+      expand: "allowed_add_ons",
@@
-      expands: "meta_fields,meta_fields.values,images"
+      expand: "meta_fields,meta_fields.values,images"
@@
-      expands: "meta_fields,meta_fields.values,images"
+      expand: "meta_fields,meta_fields.values,images"

Also applies to: 617-618, 1014-1016, 1418-1420

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/actions/sponsor-forms-actions.js` around lines 511 - 512, Replace the
incorrect request option key "expands" with the singular "expand" wherever API
call options use it (e.g., the object containing expands: "allowed_add_ons" and
the three other similar option objects in this file); update each occurrence so
the options object uses expand: "<value>" to match the codebase/OpenStack API
convention and ensure responses include the expanded fields.

access_token: accessToken
};
Expand Down Expand Up @@ -612,6 +614,7 @@ export const getSponsorCustomizedForms =
page,
fields:
"id,code,name,is_archived,opens_at,expires_at,items_count,allowed_add_ons",
expands: "allowed_add_ons",
per_page: perPage,
access_token: accessToken
};
Expand Down Expand Up @@ -653,6 +656,7 @@ export const getSponsorCustomizedForm =
const params = {
fields:
"id,code,name,is_archived,opens_at,instructions,expires_at,items_count,allowed_add_ons,meta_fields",
expand: "allowed_add_ons,meta_fields,meta_fields.values",
access_token: accessToken
};

Expand Down Expand Up @@ -1007,7 +1011,8 @@ export const getSponsorFormItem =
dispatch(startLoading());

const params = {
access_token: accessToken
access_token: accessToken,
expands: "meta_fields,meta_fields.values,images"
};

return getRequest(
Expand Down Expand Up @@ -1410,7 +1415,8 @@ export const getSponsorFormManagedItem =
dispatch(startLoading());

const params = {
access_token: accessToken
access_token: accessToken,
expands: "meta_fields,meta_fields.values,images"
};

return getRequest(
Expand Down
2 changes: 1 addition & 1 deletion src/reducers/sponsors/sponsor-forms-list-reducer.js
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ const sponsorFormsListReducer = (state = DEFAULT_STATE, action) => {

const sponsorshipTypeTds = form.apply_to_all_types
? ["all"]
: [...form.sponsorship_types];
: form.sponsorship_types.map((st) => st.id);
Comment on lines 115 to +117

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue | 🟠 Major

Guard sponsorship_types before mapping to IDs.

Line 117 assumes form.sponsorship_types is always an array. If it comes as null/undefined, this throws and breaks loading the form template.

Proposed fix
-      const sponsorshipTypeTds = form.apply_to_all_types
-        ? ["all"]
-        : form.sponsorship_types.map((st) => st.id);
+      const sponsorshipTypeIds = form.apply_to_all_types
+        ? ["all"]
+        : (form.sponsorship_types ?? []).map((st) =>
+            typeof st === "object" ? st.id : st
+          );
@@
-        sponsorship_types: sponsorshipTypeTds,
+        sponsorship_types: sponsorshipTypeIds,

Also applies to: 123-123

🤖 Prompt for AI Agents
Verify each finding against the current code and only fix it if needed.

In `@src/reducers/sponsors/sponsor-forms-list-reducer.js` around lines 115 - 117,
The code assumes form.sponsorship_types is always an array when creating
sponsorshipTypeTds; guard against null/undefined by defaulting to an empty array
before mapping (e.g., use (form.sponsorship_types || []) or Array.isArray check)
so that when form.apply_to_all_types is false you won't call .map on undefined.
Update the same pattern for the other mapping at the later occurrence (the
similar mapping on line 123) so both places use a safe fallback before calling
.map on sponsorship_types.


const formTemplate = {
id: form.id,
Expand Down
Loading