Fix stackId null handling in frontend API calls #10317
Open
+29
−11
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Problem
The frontend was calling the
changes_in_branch
endpoint withstackId: "null"
(string) instead ofstackId: null
(actual null value), causing API failures. The backend expectsOption<StackId>
but was receiving the string"null"
, which cannot be deserialized into the expected type.Example of the failing API call:
Root Cause
URL parameters are always strings in web APIs. When a URL contains
?stackId=null
, theURLSearchParams.get('stackId')
method returns the string"null"
instead of the actualnull
value. This string then gets passed through the application state and eventually to API calls where it should benull
.Solution
1. Fixed URL parameter processing
"null"
to actualnull
when reading URL parameters2. Fixed API method calls
branchChanges
,branchChange
, andbranchChangesByPaths
methods instackService.svelte.ts
to sanitize stackId parametersstackId === 'null' ? null : stackId
string | null
for stackId parameters3. Updated mock backend
Result
The backend now correctly receives:
This resolves the API failure while maintaining backward compatibility with existing valid stackId values. The fix is defensive and only converts the specific problematic case while preserving all other values unchanged.
Warning
Firewall rules blocked me from connecting to one or more addresses (expand for details)
I tried to connect to the following addresses, but was blocked by firewall rules:
esm.ubuntu.com
/usr/lib/apt/methods/https
(dns block)If you need me to access, download, or install something from one of these locations, you can either:
✨ Let Copilot coding agent set things up for you — coding agent works faster and does higher quality work when set up for your repo.