Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[HOLD for payment 2024-06-28] [HOLD for payment 2024-06-24] [$250] [TS Migration] Define a concise way to access or default to an inexistent record #39125

Closed
mountiny opened this issue Mar 27, 2024 · 58 comments
Assignees
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item. Task Typescript Migration

Comments

@mountiny
Copy link
Contributor

mountiny commented Mar 27, 2024

Follow up issue for TS migration project. Coming from this spreadsheet

Define a concise way to access or default to an inexistent record (0, -1, etc)

Any more details for this one cc @blazejkustra @fabioh8010

Upwork Automation - Do Not Edit
  • Upwork Job URL: https://www.upwork.com/jobs/~0127e590dfa2accb42
  • Upwork Job ID: 1780548153949810688
  • Last Price Increase: 2024-04-24
  • Automatic offers:
    • jjcoffee | Reviewer | 0
    • godofoutcasts94 | Contributor | 0
Issue OwnerCurrent Issue Owner: @johncschuster
@mountiny mountiny changed the title [TS Migration] Define a concise way to access or default to an inexistent record [HOLD TS migration completion] [TS Migration] Define a concise way to access or default to an inexistent record Mar 28, 2024
@fabioh8010
Copy link
Contributor

fabioh8010 commented Apr 16, 2024

Problem

Currently we have been defaulting nullable entity IDs to either 0 or -1 when it doesn’t exist as we can see here and here (and many other files throughout the project). The lack of conciseness when defaulting such IDs leads to confusion between developers and increased chance of bugs.

Solution

Standartise the default values of all Onyx entity IDs. Personally I think we should default all nullable entity IDs to -1 as it is a negative ID and theoretically we would never have a negative one in the DB (@mountiny makes sense to you?):

  1. For each Onyx type inside src/types/onyx/, look for properties that ends with ID?: ..., e.g. managerID?: number;, parentReportID?: string;, iouReportID?: string; inside Report.ts
  2. For each property, look for its usage throughout the codebase.
  3. If that property is being defaulted to either 0 or -1, change it to -1.
  4. Change TS_STYLE.md to include this advice of using -1 to default these kind of ID properties.
  5. Test everything extensively.

@melvin-bot melvin-bot bot added the Overdue label Apr 16, 2024
@mountiny mountiny changed the title [HOLD TS migration completion] [TS Migration] Define a concise way to access or default to an inexistent record [TS Migration] Define a concise way to access or default to an inexistent record Apr 16, 2024
@melvin-bot melvin-bot bot removed the Overdue label Apr 16, 2024
@mountiny
Copy link
Contributor Author

@fabioh8010 this makes sense to me, but I think we need to bring this up to slack for broader agreement, can you post the proposal to open source channel before proceeding?

@fabioh8010
Copy link
Contributor

@mountiny Sure, I can post! But could you make this issue External? It was marked as External initially.

@mountiny mountiny added External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item. labels Apr 17, 2024
Copy link

melvin-bot bot commented Apr 17, 2024

Job added to Upwork: https://www.upwork.com/jobs/~0127e590dfa2accb42

@melvin-bot melvin-bot bot changed the title [TS Migration] Define a concise way to access or default to an inexistent record [$250] [TS Migration] Define a concise way to access or default to an inexistent record Apr 17, 2024
@melvin-bot melvin-bot bot added the Help Wanted Apply this label when an issue is open to proposals by contributors label Apr 17, 2024
Copy link

melvin-bot bot commented Apr 17, 2024

Triggered auto assignment to @johncschuster (NewFeature), see https://stackoverflowteams.com/c/expensify/questions/14418#:~:text=BugZero%20process%20steps%20for%20feature%20requests for more details. Please add this Feature request to a GH project, as outlined in the SO.

Copy link

melvin-bot bot commented Apr 17, 2024

Triggered auto assignment to Contributor-plus team member for initial proposal review - @jjcoffee (External)

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Apr 17, 2024
@ghost
Copy link

ghost commented Apr 17, 2024

Proposal

Please re-state the problem that we are trying to solve in this issue.

Define a concise way to access or default to an inexistent record

What is the root cause of that problem?

Coming from TS Migration Issue, As discussed in the comment here - #39125 (comment), we need to look for properties that ends with ID?: ..., e.g. managerID?: number;, parentReportID?: string;, iouReportID?: string; inside Report.ts

What changes do you think we should make in order to solve the problem?

We need to standartise the default values of all Onyx entity IDs. we need to change the property to -1 in the codebase. We need to add tests for it as well. Also, as mentioned here, we need to update TS_STYLE.md to include this advice of using -1 to default these kind of ID properties.

Just an example situtaion :

Here in the Report.ts:

managerID?: number;

we have managerID?: number;. So if I search for managerID in the codebase I can find out that it is used here
ReportPreview.tsx :
const managerID = iouReport?.managerID ?? 0;

we are using const managerID = iouReport?.managerID ?? 0; and defining it as 0, so we need to update it to -1

What alternative solutions did you explore? (Optional)

N/A

@fabioh8010
Copy link
Contributor

@fabioh8010 this makes sense to me, but I think we need to bring this up to slack for broader agreement, can you post the proposal to open source channel before proceeding?

Posted here.

@fabioh8010
Copy link
Contributor

@fabioh8010 this makes sense to me, but I think we need to bring this up to slack for broader agreement, can you post the proposal to open source channel before proceeding?

Posted here.

⚠️ Solution was approved, but let's consider this additional change:

Change TS_STYLE.md to include this advice of using -1 to default these kind of ID properties.

@jjcoffee
Copy link
Contributor

@godofoutcasts94 Thanks for your proposal! It's a bit copy & pastey as it stands, so could I ask you to provide an example of a change you would make so that I can make sure you understand the issue. Thanks!

@melvin-bot melvin-bot bot added the Overdue label Apr 22, 2024
@ghost
Copy link

ghost commented Apr 23, 2024

Hey @jjcoffee sorry for late reply. Updated proposal

@melvin-bot melvin-bot bot removed the Overdue label May 28, 2024
@fabioh8010
Copy link
Contributor

@kubabutkiewicz We can also ask for a full regression test when opening the PR, would be good to have it.

@melvin-bot melvin-bot bot added Reviewing Has a PR in review Weekly KSv2 and removed Daily KSv2 labels May 31, 2024
Copy link

melvin-bot bot commented Jun 16, 2024

⚠️ Looks like this issue was linked to a Deploy Blocker here

If you are the assigned CME please investigate whether the linked PR caused a regression and leave a comment with the results.

If a regression has occurred and you are the assigned CM follow the instructions here.

If this regression could have been avoided please consider also proposing a recommendation to the PR checklist so that we can avoid it in the future.

@melvin-bot melvin-bot bot added Weekly KSv2 Awaiting Payment Auto-added when associated PR is deployed to production and removed Weekly KSv2 labels Jun 16, 2024
@melvin-bot melvin-bot bot changed the title [$250] [TS Migration] Define a concise way to access or default to an inexistent record [HOLD for payment 2024-06-24] [$250] [TS Migration] Define a concise way to access or default to an inexistent record Jun 17, 2024
Copy link

melvin-bot bot commented Jun 17, 2024

Reviewing label has been removed, please complete the "BugZero Checklist".

@melvin-bot melvin-bot bot removed the Reviewing Has a PR in review label Jun 17, 2024
Copy link

melvin-bot bot commented Jun 17, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.84-3 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-06-24. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Jun 17, 2024

BugZero Checklist: The PR adding this new feature has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@jjcoffee] Please propose regression test steps to ensure the new feature will work correctly on production in further releases.
  • [@johncschuster] Link the GH issue for creating/updating the regression test once above steps have been agreed upon.

@melvin-bot melvin-bot bot added Weekly KSv2 and removed Weekly KSv2 labels Jun 21, 2024
@melvin-bot melvin-bot bot changed the title [HOLD for payment 2024-06-24] [$250] [TS Migration] Define a concise way to access or default to an inexistent record [HOLD for payment 2024-06-28] [HOLD for payment 2024-06-24] [$250] [TS Migration] Define a concise way to access or default to an inexistent record Jun 21, 2024
Copy link

melvin-bot bot commented Jun 21, 2024

The solution for this issue has been 🚀 deployed to production 🚀 in version 1.4.85-7 and is now subject to a 7-day regression period 📆. Here is the list of pull requests that resolve this issue:

If no regressions arise, payment will be issued on 2024-06-28. 🎊

For reference, here are some details about the assignees on this issue:

Copy link

melvin-bot bot commented Jun 21, 2024

BugZero Checklist: The PR adding this new feature has been merged! The following checklist (instructions) will need to be completed before the issue can be closed:

  • [@jjcoffee] Please propose regression test steps to ensure the new feature will work correctly on production in further releases.
  • [@johncschuster] Link the GH issue for creating/updating the regression test once above steps have been agreed upon.

@johncschuster
Copy link
Contributor

Discussing in Slack to make sure I'm understanding the correct payment date

@melvin-bot melvin-bot bot added Daily KSv2 and removed Weekly KSv2 labels Jun 24, 2024
@johncschuster
Copy link
Contributor

@jjcoffee do we need a regression test for this? If so, can you propose the steps?

@johncschuster
Copy link
Contributor

Payment Summary:

Contributor: @kubabutkiewicz - does not require payment
Contributor+: @jjcoffee - $250 - paid via Upwork - PAID

@jjcoffee
Copy link
Contributor

do we need a regression test for this? If so, can you propose the steps?

@johncschuster No I don't think so, since this is an app-wide change.

@johncschuster
Copy link
Contributor

Awesome. Thank you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Awaiting Payment Auto-added when associated PR is deployed to production Daily KSv2 External Added to denote the issue can be worked on by a contributor NewFeature Something to build that is a new item. Task Typescript Migration
Projects
No open projects
Development

No branches or pull requests

8 participants