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

Created by field can't have null value #6597

Open
BOHEUS opened this issue Aug 10, 2024 · 8 comments
Open

Created by field can't have null value #6597

BOHEUS opened this issue Aug 10, 2024 · 8 comments

Comments

@BOHEUS
Copy link
Contributor

BOHEUS commented Aug 10, 2024

Scenario:

  1. Log in
  2. Go to People, Companies or Opportunities

Actual: Created by field has no data at all in some cases
image
image
image

Expected: Created by field must have data, if anything occurs leading to showing or adding new record, then error should be thrown.

@FelixMalfait
Copy link
Member

I think it does have data but the issue is the edit mode of the createdBy field which makes the value disappear

(we made createdBy nullable because we couldn't backfill some of the old data, but all new records should have a non-null createdBy)

@BOHEUS
Copy link
Contributor Author

BOHEUS commented Aug 10, 2024

@FelixMalfait I checked it using REST API and records in:

  • Opportunities have either createdBy filled with data of nonexistent creator 'Jony Ive' or null
    Fragment of Opportunities record
{
                "id": "20202020-0543-4cc2-9f96-95cc699960f2",
                "name": "Opportunity 2",
                "closeDate": "2024-08-07T21:44:31.821Z",
                "stage": "MEETING",
                "position": 2,
                "createdAt": "2024-08-07T21:44:31.819Z",
                "updatedAt": "2024-08-07T21:44:31.819Z",
                "pointOfContactId": "20202020-f517-42fd-80ae-14173b3b70ae",
                "companyId": "20202020-5d81-46d6-bf83-f7fd33ea6102",
                "amount": {
                    "amountMicros": 2000000,
                    "currencyCode": "USD"
                },
                "createdBy": {
                    "source": "MANUAL",
                    "workspaceMemberId": "20202020-77d5-4cb6-b60a-f4a835a85d61",
                    "name": "Jony Ive"
                },
...
  • Companies and People also have null value
{
               "id": "20202020-1455-4c57-afaf-dd5dc086361d",
               "name": "Algolia",
               "employees": null,
               "idealCustomerProfile": false,
               "position": 13,
               "createdAt": "2024-08-07T21:44:31.819Z",
               "updatedAt": "2024-08-07T21:44:31.819Z",
               "accountOwnerId": null,
               "accountOwner": null,
               "tagline": "Algolia's tagline",
               "workPolicy": [
                   "ON_SITE"
               ],
               "visaSponsorship": false,
               "domainName": {
                   "primaryLinkLabel": "",
                   "primaryLinkUrl": "https://algolia.com",
                   "secondaryLinks": null
               },
               "linkedinLink": {
                   "primaryLinkLabel": "",
                   "primaryLinkUrl": "",
                   "secondaryLinks": null
               },
               "xLink": {
                   "primaryLinkLabel": "",
                   "primaryLinkUrl": "",
                   "secondaryLinks": null
               },
               "annualRecurringRevenue": {
                   "amountMicros": null,
                   "currencyCode": ""
               },
               "address": {
                   "addressStreet1": null,
                   "addressStreet2": null,
                   "addressCity": null,
                   "addressPostcode": null,
                   "addressState": null,
                   "addressCountry": null,
                   "addressLat": null,
                   "addressLng": null
               },
               "createdBy": {
                   "source": "MANUAL",
                   "workspaceMemberId": null,
                   "name": ""
               },
               "people": [],
               "activityTargets": [],
               "taskTargets": [],
               "noteTargets": [],
               "opportunities": [],
               "favorites": [],
               "attachments": [],
               "timelineActivities": [],
               "introVideo": {
                   "primaryLinkLabel": "",
                   "primaryLinkUrl": "",
                   "secondaryLinks": null
               }
           },

While I'm trying to find such person, REST API returns empty record meaning this person does not exist.
image

@FelixMalfait
Copy link
Member

I'm not yet convinced there's really an issue here? As long as createBy is nullable (because of historical data), it can make sense to keep a null createdBy in the seeds imo

@BOHEUS
Copy link
Contributor Author

BOHEUS commented Aug 10, 2024

Okay, then what about the case where someone creates new Opportunity object but later they changed their job and their account was deleted? What's the business logic flow for it? I imagine that's the result of it (missing data in createdBy) and it should be fixed.

@BOHEUS
Copy link
Contributor Author

BOHEUS commented Aug 10, 2024

I found something weird, in Twenty workspace Opportunities with Jony Ive don't have data in Created by column but in Apple workspace, Opportunities have normal visible data

Twenty workspace
image

Apple workspace
image

Edit: that's because user Jony Ive exists in Apple workspace but not in Twenty workspace, so Twenty workspace, while it has correct data, can't return it due to missing record in database.

@FelixMalfait
Copy link
Member

Edit: that's because user Jony Ive exists in Apple workspace but not in Twenty workspace, so Twenty workspace, while it has correct data, can't return it due to missing record in database.

Ah yes good catch, that should be an easy fix in the seeds! You can replace in typeorm-seeds/workspace/opportunities.ts, DEV_SEED_WORKSPACE_MEMBER_IDS.JONY by DEV_SEED_WORKSPACE_MEMBER_IDS.TIM which belongs to both workspace. You want to raise the PR for it 😁? Thanks

@BOHEUS
Copy link
Contributor Author

BOHEUS commented Aug 12, 2024

Sure, I'll create a PR.

@BOHEUS
Copy link
Contributor Author

BOHEUS commented Aug 13, 2024

@FelixMalfait I have scenario to reproduce this bug, while my changes fixed the problem with "wrong" data, it still exists (the business logic flow I wrote earlier)

Scenario:

  1. Log in
  2. Go to Settings > Members
  3. Copy invite link
  4. Open new browser and paste the copy link
  5. Create an account
  6. Create new People, Company or Opportunity object (Actual: newly created member isn't visible in Created by field)
  7. Refresh page (now it's visible)
  8. Go back to browser from step 1
  9. Go to Settings > Members and delete member created in step 5
  10. Refresh page and check object(s) from step 6

Actual: Created by field has missing data
Expected: Created by field should have data of deleted member (API response from earlier shows that object has stored creator's first and last name), after clicking on this member it shouldn't redirect to it's page as member object doesn't exist in database so link for its' profile can't be generated (to be decided by @CoreTeamTwenty)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
Status: 🆕 New
Development

No branches or pull requests

3 participants