Skip to content

Conversation

@kevinkim-ogp
Copy link
Contributor

  • Fix Excel get table rows function
  • Improve editor interactions in published pipes
  • Retry Postman SMS on Cloudflare errors
  • Remove manually uploaded attachments when duplicating Pipe

kevinkim-ogp and others added 6 commits June 4, 2025 11:59
## Problem
Postman SMS actions face intermittent errors when calling the API due to
520 / 524, which are Cloudflare-specific HTTP status codes indicating
issues between Cloudflare and the origin server.
current implementation leads to failures and require manual retries,
when there is in fact nothing wrong with the user's set up or input data

## Solution
Enable auto-retries for postman sms when encountering 520 or 524 status
codes.

## How to test?
Set up Postman SMS action first, modify to call 520 or 524 
(use https://status-codes-eight.vercel.app/api/520, since mock.codes
does not have 520 or 524)
- [ ] Verify that action is retried when 520 / 524 is returned
- [ ] Verify that action fails after the default number of retries (10)
## Problem

Users can modify the frontend input for published pipes but it does not
affect the backend

## Solution
- Add readonly attribute to all inputs

## Tests
Check that inputs can be edited when unpublished and cannot be edited
when published
- [ ] BooleanRadio type: telegram
- [ ] DragDropInput type: formsg connection
- [ ] Dropdown: tiles
- [ ] RichTextEditor: postman email
- [ ] TextField: `readOnly: true` is for slack auth only, everything
else e.g. aisay prompt is false
- [ ] Attachment: postman email attachment
- [ ] MultiSelect: old postman email attachment, not used anywhere now
(manually change to test)
- [ ] MultiRow: aisay, tiles
- [ ] MultiRow-MultiCol: custom-api headers
## Problem
Manually uploaded attachments in the Email by Postman step are not
handled properly when duplicating Pipe as it is not copied to a new S3
bucket and step parameters are still referencing the old attachment.
It causes the following error:

![image](https://github.com/user-attachments/assets/a2618398-ee85-4a0a-b40d-ccaf89999b60)

**How to replicate**
1. Create a Pipe with Email by Postman action
2. Upload your own attachment
3. Check step
4. Duplicate the pipe
5. Delete attachment from the action in the duplicated Pipe
6. Check step
7. See the error

## Solution
This is a short-term solution to address the issue when duplicating a
Pipe:
* Remove all manually uploaded attachments from the Pipe's config
* Remove all manually uploaded attachments from the Email by Postman's
step parameters
  * Does a check to remove step parameter values that start with `s3:`
* Confirmed that only manually uploaded attachments have this prefix in
their value

**NOTE**: The long-term solution to follow in the future would be to
duplicate the attachments in the S3 bucket and update the step
parameters in the Email by Postman actions.

## What changed?
* Remove `attachments` from the config of the newly duplicated Pipe
* Remove all manually uploaded attachments from the Email by Postman's
step parameters
* Refactor to helper function
* Add functionality to handle nested objects
* Add tests for the helper functions

## How to test?
1. Create a Pipe with both FormSG and manually uploaded attachments
2. Duplicate this Pipe
3. Open the duplicated Pipe
4. Run 'Check step' on the FormSG step
5. Check that Postman step ONLY contains the FormSG attachments and does
not contain the manually uploaded attachment
6. Manually upload an attachment and 'Check step'
7. Verify that email is sent with both form and manually uploaded
attachments

## Screenshots


https://github.com/user-attachments/assets/7463e2c7-122f-4f8c-9a9f-f865ae767db4
## Problem
* Cannot select options in SingleSelect in edit mode (e.g., Tiles
column)
* Cannot open Suggestions Popover in edit mode

## Solution
**Bug Fixes**:
- Fix onChange in SingleSelect in edit mode
- Allow Suggestions Popover to open in readonly, but disable selection
  - Autofocus on the Popover in readonly to close the popover on blur 

## Tests
- [ ] Can select options in SingleSelect fields, e.g., Tiles find single
row column or filter selector
- [ ] Popover opens in PUBLISHED pipe (both RTE and attachments)
  - [ ] Cannot select any variable in Popover
  - [ ] Cannot delete attachment in Popover

---------

Co-authored-by: Ian Chen <[email protected]>
## Problem

Excel `getTopNTableRows` is buggy because `usedRange` includes all
non-empty cells (not limited to a table)
It can accidentally include:
- Stray formatting
- Other tables if you resize too far

There's no way to limit `usedRange` to a table specifically — it works
on worksheet or relative range context

## Solution
Considering using `range` which gives both the header row and data rows
as well as the `headerSheetRowIndex`, keeping the API call to still be
1: only select `values`, `rowCount` and `rowIndex` from the table to
speed up the query.

However, if the table is huge (>100k rows), it will take very long to
execute and timeout which is not ideal.

Settled for:
Using the `rows` API, and it involves pagination so the query takes
around 5s for a table of 50k rows
Also considered using the `columns` API, but it does not return the
`headerSheetRowIndex` address so another API query has to be made to
obtain it

Tried doing batching to save on 1 API call each but it takes around 2s
to perform the request even for small tables. Running a batch of 10
calls also take around 3s, making the tradeoff for running 1 batch of 2
calls not worth compared to 2 different API calls

Tested on staging that the query takes approximately the same time as
old method: 30 executions completed in 30s due to the excel queue rate
limit.

## Tests
`getTableRow` action:
- [x] Works for multiple found rows (the first row found is returned)
- [x] Values outside the table will not be retrieved

`updateTableRow` action:
- [x] Works for multiple found rows (the first row found is returned)
- [x] Values outside the table will not be retrieved
@kevinkim-ogp kevinkim-ogp requested a review from a team as a code owner June 9, 2025 03:11
@datadog-opengovsg
Copy link

Datadog Report

Branch report: develop-v2
Commit report: 5c7dee1
Test service: plumber

✅ 0 Failed, 818 Passed, 0 Skipped, 2m 32.8s Total Time
➡️ Test Sessions change in coverage: 1 no change

@pregnantboy pregnantboy merged commit 7d2dd8a into production Jun 9, 2025
7 checks passed
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.

4 participants