Skip to content

fix: double decode params in cluster methods middleware#1180

Merged
Assem-Uber merged 4 commits intocadence-workflow:masterfrom
Assem-Uber:bugfix/CDNC-15454/fix-decode-issue-in-middlwares
Feb 19, 2026
Merged

fix: double decode params in cluster methods middleware#1180
Assem-Uber merged 4 commits intocadence-workflow:masterfrom
Assem-Uber:bugfix/CDNC-15454/fix-decode-issue-in-middlwares

Conversation

@Assem-Uber
Copy link
Contributor

@Assem-Uber Assem-Uber commented Feb 19, 2026

Summary

Next.js App Router already decodes dynamic route params before passing them to API routes & our custom middlewares. This change removes redundant decoding in the gRPC cluster methods middleware so we don’t double-decode and avoid URIError or corrupted values (e.g. workflowIds 100% or @).

Changes

  • Removed decodeUrlParams import and usage; middleware now uses params from the handler as-is and passes params.cluster directly to getClusterMethods().
  • Removed decodeUrlParams mock and all assertions that it was called; tests now assert that getClusterMethods is called with mockParams.cluster and that params are passed through unchanged.

Fix Plans

  • Fix custom middleware double decoding ✅
  • Fix Summary page/apis double decoding
  • Fix tasklist page/apis double decoding
  • Fix workflow query diagnostics api double decoding
  • Fix workflow actions double decoding
  • Fix domain page/apis double decoding

Testing

  • Tested opening workflow with special characters in workflowId http://localhost:8088/domains/default/cluster0/workflows/%23%24%40%5E%25%24%40%5E%23%25%24%5E%26%40/e00efb14-c148-4f48-be8f-f4fc066e2d97/summary

  • Error before the fix:

Screenshot 2026-02-19 at 11 00 59
  • Error no longer happens, while the page is still not loading due to double decoding happening in other pages that is going to be addressed in next PRs.
  • Logging nextjs params from within the middleware, shows it is already decoded
Screenshot 2026-02-19 at 11 16 36

@Assem-Uber Assem-Uber changed the title fix decode params in cluster methods fix: double decode params in cluster methods middleware Feb 19, 2026
@Assem-Uber Assem-Uber marked this pull request as ready for review February 19, 2026 10:18
Copy link
Contributor

Copilot AI left a comment

Choose a reason for hiding this comment

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

Pull request overview

Removes redundant URL parameter decoding from the gRPC cluster methods route-handler middleware to avoid double-decoding issues with Next.js App Router dynamic route params (e.g., %, @) and updates tests accordingly.

Changes:

  • Removed decodeUrlParams usage in grpcClusterMethods and passed params.cluster through directly to getClusterMethods.
  • Updated middleware unit tests to stop mocking/asserting decodeUrlParams and instead assert pass-through behavior.

Reviewed changes

Copilot reviewed 2 out of 2 changed files in this pull request and generated 2 comments.

File Description
src/utils/route-handlers-middleware/middlewares/grpc-cluster-methods.ts Stops decoding params in the middleware and forwards params.cluster directly to getClusterMethods.
src/utils/route-handlers-middleware/middlewares/tests/grpc-cluster-methods.test.ts Removes decodeUrlParams mocking/assertions and validates getClusterMethods is called with the raw params.

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

Comment on lines 21 to 23
const clusterMetods = await getClusterMethods(params.cluster, grpcMetadata);

return ['grpcClusterMethods', clusterMetods];
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

Local variable name clusterMetods appears to be misspelled (missing the 'h'). Renaming it to clusterMethods would improve readability and avoid propagating the typo in future edits.

Suggested change
const clusterMetods = await getClusterMethods(params.cluster, grpcMetadata);
return ['grpcClusterMethods', clusterMetods];
const clusterMethods = await getClusterMethods(params.cluster, grpcMetadata);
return ['grpcClusterMethods', clusterMethods];

Copilot uses AI. Check for mistakes.
Comment on lines +34 to +38
@@ -41,21 +35,17 @@ describe('grpcClusterMethods middleware', () => {
).rejects.toMatchObject(Error('Cluster not found: undefined'))
);
});
it('should decode URL params and call getClusterMethods with correct arguments', async () => {
(decodeUrlParams as jest.Mock).mockReturnValue(mockDecodedParams);

it('should pass params through and call getClusterMethods with correct arguments', async () => {
Copy link

Copilot AI Feb 19, 2026

Choose a reason for hiding this comment

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

The rejection assertion in the preceding test is wrapped in an extra expect(...)/await (i.e., await expect(await expect(promise).rejects...)), which adds no assertion and makes the test harder to read. Consider simplifying to a single await expect(grpcClusterMethods(...)).rejects....

Copilot uses AI. Check for mistakes.
@Assem-Uber Assem-Uber merged commit f85f67d into cadence-workflow:master Feb 19, 2026
3 checks passed
@Assem-Uber Assem-Uber deleted the bugfix/CDNC-15454/fix-decode-issue-in-middlwares branch February 19, 2026 13:29
adhityamamallan pushed a commit to adhityamamallan/cadence-web that referenced this pull request Feb 19, 2026
…flow#1180)

* fix decode params in cluster methods

* fix double decoding

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Assem-Uber added a commit to Assem-Uber/cadence-web that referenced this pull request Feb 19, 2026
…flow#1180)

* fix decode params in cluster methods

* fix double decoding
Assem-Uber added a commit that referenced this pull request Feb 20, 2026
* fix decode params in cluster methods

* fix url decode in worfklow actions APIs

* refactor: Move history scroll handlers to dedicated hook (#1156)

* Move code for Workflow History V2 scroll handlers (scroll to event, scroll up, scroll down) and variables (Virtuoso refs) to dedicated React hook
* Fix a minor bug with scrollToEvent where it would not work with the first event

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>

* refactor: rename onClickEvent to onClickShowInTable in Workflow History Timeline (#1157)

* To prepare for moving the click handling for events to a dedicated "Show in table" button, this PR renames the onClickEvent handler to onClickShowInTable

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>

* Lift timeline state up to workflow history root (#1158)

Lift timeline state up from WorkflowHistoryHeader to WorkflowHistoryV2, allowing sub-components in the list to open the timeline if necessary.

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>

* refactor: Use groupId from Event Groups entries instead of firstEventId in Workflow History Timeline (#1160)

Instead of setting the row ID as the firstEventId for Workflow History Timeline rows, this PR passes the groupId (which, in practice, is the exact same thing) to the getTimelineRowFromEventGroup helper

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>

* fix: Show correct error banner message when failing to load domains from some clusters  (#1162)

Problem
When the Cadence UI fails to connect to some clusters to load domains, we show an error banner with the list of problematic clusters. However, this banner currently lists all clusters instead of just the problematic ones. This is due to a mistake in the logic for evaluating problematic clusters.

Solution
Fix the logic for evaluating problematic clusters
Break the getAllDomains helper up into separate helpers for better testability

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>

* fix: Add cron schedule descriptions to Workflow History V2 components (#1163)

Add natural-language Cron descriptions (implemented in #1151) to Workflow History V2 details parsers config

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>

* fix: Use ClustersConfigs type in getAllDomains unit test (#1165)

* Use server-side ClustersConfigs type and existing clusters configs fixtures in unit test for getAllDomains, to prevent getConfigValue's spy from assuming that it's of type PublicClustersConfigs (client-side)
* Rename setup param to clustersConfigs from clusterConfigs, to match the type

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>

* fix: Add explicit "Copy link" text to history event link copy button (#1166)

* Add explicit "Copy link" text to history event link copy button in accordance with existing designs, to make the button's intent clearer without needing to hover on it
* Remove the "Copy link to event" tooltip that shows up when user initially hovers on the link button

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>

* feat: Add timeline scroll handler & target to useWorkflowHistoryScroll (#1167)

* Add timeline Virtuoso ref, scroll handler and scroll target (event group) to useWorkflowHistoryScroll, to use for timeline <-> table integration

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>

* feat: Warning message when no workers are available for a task list (#1168)

Signed-off-by: Yoav Levy <yoavlev2@gmail.com>

* feat: Add "Show in Timeline" button to event groups in grouped Workflow History table (#1169)

* Add timeline scroll handler in useWorkflowHistoryScroll hook with similar pattern to existing table scroll
* Add "Show in timeline" button in event group details panel that scrolls to and highlights the group in the timeline
* Implement animation effect for highlighted timeline rows using 2-second fade transition

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>

* feat: Add "Show in Table" button to event groups in Workflow History Timeline (#1171)

* Add "Show in Table" button to event groups in Workflow History Timeline, to highlight event groups in the Workflow History tables
* Remove the onClick functionality from the timeline event bar
* Increase tooltip entry time to 600ms (and define it in a constant instead of hardcoding it)
* Increase spacing between event tabs and action buttons from scale400 (12px) to scale1200 (48px)

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>

* feat: Add "Show in Timeline" button to events in ungrouped Workflow History table (#1170)

* Add the Show in Timeline button (added in #1169) to the ungrouped Workflow History table
* Add groupId to UngroupedEventsInfo
* Move createUngroupedEventsInfo test util to fixtures directory

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>

* fix: Improper wrapping & overflow on Workflow Summary page (#1174)

* Rewrite the styles to use a simpler grid-based layout, distributing the space evenly between the summary details and the JSON panels
* Allow the workflow title to overflow onto multiple lines

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>

* fix: Constrain size of group details tooltip in Workflow History timeline (#1176)

* Constrain max width of the tooltip to 800px
* Add an isScrollable prop to WorkflowHistoryEventDetails, constraining the height of non-panel details to 250px and making them scrollable if true
* Pass this prop through from WorkflowHistoryTimelineEventGroup

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>

* feat: Dynamically resize history timeline for running workflows (#1172)

* Add hook useCurrentTimeMs to accurately calculate the current time every second, instead of letting it be recalculated only on rerenders.
* Add hook useSteppedDomainMaxMs to calculate the timeline's max domain based on events and current time
Change the implementation of getTimelineMaxTimeMs to take current time as a parameter instead of calling Date.now() inside it
* For running events without an end time (so, any running events besides timers), use current time as the bar's end point, so that bars smoothly expand
* Add an outline to the timeline component
* Move header padding to timeline container margin (still size400/16px)
* Remove border between header cells

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>

* fix: double decode params in cluster methods middleware (#1180)

* fix decode params in cluster methods

* fix double decoding

* add search attribute api

* fix: Stop click propagation when clicking on Workflow History summarized details (#1175)

* Add new field hasClickableContent to details row item config, which is set if the item is meant to be clickable
* Set this field to true for all existing links
* Call e.stopPropagation() in the details entry onClick handler to prevent the click from propagating to parents, if hasClickableContent is true


Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>

* refactor: Move types from workflow-history.types.ts to workflow-history-v2.types.ts (#1177)

* Move Workflow History types from v1 folder to v2 folder, to prepare for changes to history event group computation
* Refactor v2 code to use the types from workflow-history-v2.types.ts

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>

* fix: Double decode issue for summary page (#1183)

* fix decode params in cluster methods

* fix double decoding

* fix double encoding for summary page

* revert search attributes changes

---------

Signed-off-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Signed-off-by: Yoav Levy <yoavlev2@gmail.com>
Co-authored-by: Adhitya Mamallan <adhitya.mamallan@uber.com>
Co-authored-by: Yoav Levy <yoavlev2@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants