PromucFlow_constructor/app/server
Nilansh Bansal 56936866e1
fix: trigger instance re-registration if not already registered (#31610)
## Description

Ref:
https://theappsmith.slack.com/archives/C040LHZN03V/p1700206435426579
## Background 
At the start of the new appsmith server, we register the instanceId with
cloud services by invoking the cloud services api. For some of the
instances, if this register api call didn't go through, the cloud
services db will not have the instanceId.

While connecting to GSheets, we do a check if the request is coming from
a valid registered instance, and if it is not present this api fails.

The appsmith mongo database config collection, keeps a record of whether
this instance was registered or not.
In some scenarios, the appsmith_registered field shows that the instance
is registered but it is not as instanceId is missing in CS, i.e. the
appsmith server has the info that the instance is registered with CS but
the CS db has not registered the instance.

> This PR triggers the re-registration flow to the cloud services if the
instance is not registered.
> When calling the google sheets API to cloud services, if the response
received is 403 FORBIDDEN, it indicates the instance is not registered,
in which scenario we retrigger the registeration flow and call the CS
again.

#### PR fixes following issue(s)
Fixes #28952 

#### Media
> DEMO

https://drive.google.com/file/d/1cVluIAQlzxwb7A2bgBBMJ0I4awSV6fKp/view?usp=sharing
#### Type of change
- Bug fix (non-breaking change which fixes an issue)

## Testing
#### How Has This Been Tested?

- [x] Manual
- [ ] JUnit
- [ ] Jest
- [ ] Cypress


## Checklist:
#### Dev activity
- [x] My code follows the style guidelines of this project
- [x] I have performed a self-review of my own code
- [x] I have commented my code, particularly in hard-to-understand areas
- [ ] I have made corresponding changes to the documentation
- [x] My changes generate no new warnings
- [ ] I have added tests that prove my fix is effective or that my
feature works
- [x] New and existing unit tests pass locally with my changes
- [ ] PR is being merged under a feature flag


#### QA activity:
- [ ] [Speedbreak
features](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#speedbreakers-)
have been covered
- [ ] Test plan covers all impacted features and [areas of
interest](https://github.com/appsmithorg/TestSmith/wiki/Guidelines-for-test-plans#areas-of-interest-)
- [ ] Test plan has been peer reviewed by project stakeholders and other
QA members
- [ ] Manually tested functionality on DP
- [ ] We had an implementation alignment call with stakeholders post QA
Round 2
- [ ] Cypress test cases have been added and approved by SDET/manual QA
- [ ] Added `Test Plan Approved` label after Cypress tests were reviewed
- [ ] Added `Test Plan Approved` label after JUnit tests were reviewed

## Automation

/ok-to-test tags=""

### 🔍 Cypress test results
<!-- This is an auto-generated comment: Cypress test results  -->
> [!CAUTION]  
> If you modify the content in this section, you are likely to disrupt
the CI result for your PR.

<!-- end of auto-generated comment: Cypress test results  -->
2024-03-15 14:31:35 +05:30
..
.run feat: Databricks plugin (#29746) 2023-12-26 10:04:09 +05:30
appsmith-git chore: Fix double-brace-initialization (#31643) 2024-03-11 11:54:25 +05:30
appsmith-interfaces Revert "chore: Add separate request/response views (#31640)" 2024-03-14 11:56:59 +05:30
appsmith-plugins fix: Making userTag a hidden field to not expose it as a user configurable option with Appsmith being the default value (#31792) 2024-03-14 16:18:44 +05:30
appsmith-server fix: trigger instance re-registration if not already registered (#31610) 2024-03-15 14:31:35 +05:30
envs chore: Remove unused services (#30292) 2024-01-23 05:43:16 +05:30
mongo-seed
reactive-caching chore: Use Lombok's FieldNameConstants instead of QueryDSL (#31269) 2024-02-26 16:33:07 +05:30
scripts chore: Tiny NodeJS script as a linter for field name constants (#31766) 2024-03-14 06:30:40 +05:30
.gitignore chore: Removed failed tests file from git (#29602) 2023-12-14 13:02:36 +05:30
build.sh
buildpack-run.sh
docker-compose.yml
pom.xml chore: Revert Upgrade Mockito and surefire plugin (#31073) (#31334) 2024-02-28 14:49:41 +05:30
Procfile
README.md
system.properties

Appsmith Server

This is the server-side repository for the Appsmith framework.

For details on setting up your development machine, please refer to this Setup Guide.