You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@superset.apache.org by "jakubhruby (via GitHub)" <gi...@apache.org> on 2025/10/14 13:09:44 UTC
[PR] fix(frontend) double prefixed API url [superset]
jakubhruby opened a new pull request, #35641:
URL: https://github.com/apache/superset/pull/35641
### SUMMARY
When app root prefix is applied (e.g. `SUPERSET_APP_ROOT="/app-prefix"`), it's applied twice - e.g. when exporting graph to CSV
```javascript
// in this handler url is build with appRoot prefix
exportChart = async (...) => {
...
url = ensureAppRoot('/api/v1/chart/data');
// now the url is /app-prefix/api/v1/chart/data
// postForm is called with prefixed url
SupersetClient.postForm(url, ...)
...
}
// this method is called with already prefixed url
async postForm(endpoint, ...) {
...
hiddenForm.action = this.getUrl({ endpoint });
// now the url is /app-prefix/app-prefix/api/v1/chart/data
...
}
```
### BEFORE/AFTER SCREENSHOTS OR ANIMATED GIF
<img width="1430" height="867" alt="SnΓmek obrazovky z 2025-10-14 14-53-35" src="https://github.com/user-attachments/assets/cb224e24-3d58-4bba-9237-cec528c454d9" />
### TESTING INSTRUCTIONS
Test downloading CSV file.
### ADDITIONAL INFORMATION
- [ ] Has associated issue:
- [ ] Required feature flags:
- [ ] Changes UI
- [ ] Includes DB Migration (follow approval process in [SIP-59](https://github.com/apache/superset/issues/13351))
- [ ] Migration is atomic, supports rollback & is backwards-compatible
- [ ] Confirm DB migration upgrade and downgrade tested
- [ ] Runtime estimates and downtime expectations provided
- [ ] Introduces new feature or API
- [ ] Removes existing feature or API
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend): double prefixed API url [superset]
Posted by "jakubhruby (via GitHub)" <gi...@apache.org>.
jakubhruby commented on PR #35641:
URL: https://github.com/apache/superset/pull/35641#issuecomment-4324711538
Duplicated and replaced by https://github.com/apache/superset/pull/38513
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend) double prefixed API url [superset]
Posted by "korbit-ai[bot] (via GitHub)" <gi...@apache.org>.
korbit-ai[bot] commented on code in PR #35641:
URL: https://github.com/apache/superset/pull/35641#discussion_r2429115636
##########
superset-frontend/src/explore/exploreUtils/index.js:
##########
@@ -258,10 +259,10 @@ export const exportChart = async ({
formData,
endpointType,
allowDomainSharding: false,
- });
+ }).replace(new RegExp(`^${applicationRoot()}`), ''); // appRoot will be added in SuperstClient.postForm method
Review Comment:
### Inefficient regex creation in hot path <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
Regular expression is created on every function call instead of being cached or using a more efficient string operation.
###### Why this matters
Creating a new RegExp object on each function execution adds unnecessary overhead, especially if exportChart is called frequently. This impacts performance through repeated object instantiation and regex compilation.
###### Suggested change β *Feature Preview*
Cache the regex pattern outside the function or use string methods like `startsWith()` and `slice()` for better performance:
```javascript
const APP_ROOT_REGEX = new RegExp(`^${applicationRoot()}`);
// Then use: url.replace(APP_ROOT_REGEX, '')
// Or better: url.startsWith(appRoot) ? url.slice(appRoot.length) : url
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e1da95ba-a207-40b4-bb14-521d4ca7221b/upvote) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e1da95ba-a207-40b4-bb14-521d4ca7221b?what_not_true=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e1da95ba-a207-40b4-bb14-521d4ca7221b?what_out_of_scope=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e1da95ba-a207-40b4-bb14-521d4ca7221b?what_not_in_standard=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/e1da95ba-a207-40b4-bb14-521d4ca7221b)
</details>
<sub>
π¬ Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:11e5f4e5-13d7-4790-a450-44c61f4a5bb2 -->
[](11e5f4e5-13d7-4790-a450-44c61f4a5bb2)
##########
superset-frontend/src/explore/exploreUtils/index.js:
##########
@@ -258,10 +259,10 @@ export const exportChart = async ({
formData,
endpointType,
allowDomainSharding: false,
- });
+ }).replace(new RegExp(`^${applicationRoot()}`), ''); // appRoot will be added in SuperstClient.postForm method
Review Comment:
### Unescaped regex pattern in applicationRoot replacement <sub></sub>
<details>
<summary>Tell me more</summary>
###### What is the issue?
The regex replacement uses an unescaped applicationRoot() value which could contain special regex characters, potentially causing incorrect string replacement or regex errors.
###### Why this matters
If applicationRoot() returns a string containing regex metacharacters like '.', '+', '*', '?', '^', '$', '(', ')', '[', ']', '{', '}', '|', '\', the regex will not match the intended literal string and may cause unexpected behavior or runtime errors.
###### Suggested change β *Feature Preview*
Escape the applicationRoot() value before using it in the regex pattern:
```javascript
}).replace(new RegExp(`^${applicationRoot().replace(/[.*+?^${}()|[\]\\]/g, '\\$&')}`), ''); // appRoot will be added in SuperstClient.postForm method
```
Alternatively, use a simpler string-based approach:
```javascript
const appRoot = applicationRoot();
if (url.startsWith(appRoot)) {
url = url.substring(appRoot.length);
}
```
###### Provide feedback to improve future suggestions
[](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/682872a1-ada2-46c0-9334-5fb5cf1dc354/upvote) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/682872a1-ada2-46c0-9334-5fb5cf1dc354?what_not_true=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/682872a1-ada2-46c0-9334-5fb5cf1dc354?what_out_of_scope=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/682872a1-ada2-46c0-9334-5fb5cf1dc354?what_not_in_standard=true) [](https://app.korbit.ai/feedback/aa91ff46-6083-4491-9416-b83dd1994b51/682872a1-ada2-46c0-9334-5fb5cf1dc354)
</details>
<sub>
π¬ Looking for more details? Reply to this comment to chat with Korbit.
</sub>
<!--- korbi internal id:7f672dbf-f9a8-4386-bf97-76bcabc3b5c0 -->
[](7f672dbf-f9a8-4386-bf97-76bcabc3b5c0)
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend): double prefixed API url [superset]
Posted by "rusackas (via GitHub)" <gi...@apache.org>.
rusackas commented on PR #35641:
URL: https://github.com/apache/superset/pull/35641#issuecomment-4320871955
@jakubhruby β friendly ping on this one. It's been sitting for a few months and has picked up some blockers:
- Merge conflicts against `master` β needs a rebase.
- CI is currently failing.
- A couple of korbit-ai suggestions on `superset-frontend/src/explore/exploreUtils/index.js:262` are still open (regex escaping + avoiding RegExp creation in a hot path) β worth a look while you're in there, though they're optional.
If you're still interested in landing this fix, could you rebase and push? Otherwise we can close it out and revisit later. No rush β just trying to keep the queue tidy.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend): double prefixed API url [superset]
Posted by "jakubhruby (via GitHub)" <gi...@apache.org>.
jakubhruby closed pull request #35641: fix(frontend): double prefixed API url
URL: https://github.com/apache/superset/pull/35641
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org
Re: [PR] fix(frontend): double prefixed API url [superset]
Posted by "jakubhruby (via GitHub)" <gi...@apache.org>.
jakubhruby commented on PR #35641:
URL: https://github.com/apache/superset/pull/35641#issuecomment-4324717048
closing
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@superset.apache.org
For additional commands, e-mail: notifications-help@superset.apache.org