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

FIX: separate urn with non-nested-pattern for now #5383

Merged
merged 5 commits into from
Oct 15, 2024

Conversation

gilluminate
Copy link
Contributor

@gilluminate gilluminate commented Oct 15, 2024

Closes HJ-36

Description Of Changes

This is a bit of a bandaid fix to handle nested fields on the frontend. We are specifying something other than . used in nested field names for the URN so that we can distinguish those. More robust fixes are happening on both the BE and FE in separate tickets.

Code Changes

  • Specify a non-period separator for FE logic
  • Apply some best practices to the Edit drawer and Breadcrumbs to avoid race conditions during E2E testing and for optimization in general.

Steps to Confirm

  1. Click it
  2. Click example_table
  3. Ensure that you can still add/remove Categories from the "Can save data category changes" fields.
  4. Click through to the nested field example_nested_field
  5. The field example_failure_nested_field.1 with description "Fail to save data category changes on nested field with '.' in name" should now be able to add/remove categories.
  6. Click "edit" on the same example_failure_nested_field.1 row and make sure you can still "Save"
  • If the dataset example_dataset_issue_hj36 does not exist
  1. Click "+ Add Dataset" button
  2. Click "Upload a Dataset YML"
  3. Paste the following into the editor:
- fides_key: example_dataset_issue_hj36
  organization_fides_key: default_organization
  tags: null
  name: example_dataset_issue_hj36
  description: Minimal dataset reproducing issue (HJ-36)
  meta: null
  data_categories: null
  fides_meta: null
  collections:
    - name: example_table
      description: null
      data_categories: null
      fields:
        - name: example_nested_field
          description: null
          data_categories: null
          fides_meta: null
          fields:
            - name: example_success_nested_field
              description: Can save data category changes on nested field
              data_categories:
                - user.device
              fides_meta: null
              fields: []
            - name: example_failure_nested_field.1
              description: >-
                Fail to save data category changes on nested field with '.' in
                name
              data_categories:
                - user.location
                - system
              fides_meta: null
              fields: []
        - name: example_success_field
          description: Can save data category changes
          data_categories:
            - user.device
          fides_meta: null
          fields: null
        - name: example_success_field.1
          description: Can save data category changes
          data_categories:
            - user.device
          fides_meta: null
          fields: null
      fides_meta: null
  1. Click "Create dataset" button
  2. Proceed to follow steps 1-6 above for the example_dataset_issue_hj36 dataset

Pre-Merge Checklist

  • All CI Pipelines Succeeded
  • Issue Requirements are Met
  • Relevant Follow-Up Issues Created
  • Update CHANGELOG.md

Copy link

vercel bot commented Oct 15, 2024

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
fides-plus-nightly ✅ Ready (Inspect) Visit Preview 💬 Add feedback Oct 15, 2024 8:16pm

Copy link

cypress bot commented Oct 15, 2024

fides    Run #10452

Run Properties:  status check passed Passed #10452  •  git commit 68d419a874 ℹ️: Merge 52021b633d69bb02a929c94c4e44b741fb24bac8 into 7038f614920aa503e0494dd64290...
Project fides
Run status status check passed Passed #10452
Run duration 00m 36s
Commit git commit 68d419a874 ℹ️: Merge 52021b633d69bb02a929c94c4e44b741fb24bac8 into 7038f614920aa503e0494dd64290...
Committer Jason Gill
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 4
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

@gilluminate gilluminate force-pushed the HJ-36-dataset-with-nested-fields branch from d23329b to a199567 Compare October 15, 2024 17:32
@gilluminate gilluminate force-pushed the HJ-36-dataset-with-nested-fields branch from 889c5e7 to daa7330 Compare October 15, 2024 18:12
@gilluminate gilluminate marked this pull request as ready for review October 15, 2024 18:14
@gilluminate gilluminate force-pushed the HJ-36-dataset-with-nested-fields branch from b437e1b to 4b37cfc Compare October 15, 2024 18:41
Copy link
Contributor

@lucanovera lucanovera left a comment

Choose a reason for hiding this comment

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

I reproduced the issue and confirmed that it's fix in this branch. The code looks good. left a minor question below. approved!

const collectionIndex = dataset?.collections.indexOf(collection!);
const collectionIndex = useMemo(
() => dataset?.collections.indexOf(collection),
// eslint-disable-next-line react-hooks/exhaustive-deps
Copy link
Contributor

Choose a reason for hiding this comment

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

i'm curious, did it cause an issue trying to add the deps?

Copy link
Contributor Author

@gilluminate gilluminate Oct 15, 2024

Choose a reason for hiding this comment

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

This was causing a test to fail and I believe it's because the supplied collection was no longer matching anything in the dataset after a save. Since we're now requiring both dataset and collection to be available from the start, we want to snag this index and then stop worrying about it once either gets updated. Including the dependencies recreates the problem.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I think if I were to rewrite this, I'd pass in the index rather than the collection but this seemed like the less risky fix.

@@ -29,3 +29,5 @@ export const FIELD = {
"Arrays of Data Category resources, identified by fides_key, that apply to this field.",
},
};

export const URN_SEPARATOR = "/";
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice quick solution changing the separator to something different.
Although this makes me wonder, could we expect to have "/" as a part of the name too? 😂

Anyways, we shouldn't have accepted dots as part of the name either, and kirk is working on a fix for that.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes, it's party why I made this a constant we can update. We can come back and tweak if it's still a problem for other data.

@@ -260,46 +261,48 @@ const FieldsDetailPage: NextPage = () => {
DatasetField | undefined
>();

const breadcrumbs = useMemo(() => {
Copy link
Contributor

Choose a reason for hiding this comment

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

Good optimization!

isOpen={isEditingCollection}
onClose={() => setIsEditingCollection(false)}
/>
{dataset && selectedCollectionForEditing && (
Copy link
Contributor

Choose a reason for hiding this comment

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

Nice, avoiding needing to use the ! or handling undefined values further down.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

IMO we should avoid ! always. It's usually an indication for a potential bug, as was the case here.

@lucanovera
Copy link
Contributor

@gilluminate While testing I found another bug that would be very easy to fix, can we include it here?

The bug is that in the table view if you try to add a category by adding the plus icon, it will navigate down to the nested field level.

In src/pages/dataset/[datasetId]/[collectionName]/index.tsx the data categories column is missing this option:
meta: { disableRowClick: true, },

It won't cause an issue here src/pages/dataset/[datasetId]/[collectionName]/[subfieldUrn].tsx but we could add it for consistency too.

@gilluminate gilluminate force-pushed the HJ-36-dataset-with-nested-fields branch from 4b37cfc to 0cfcbcb Compare October 15, 2024 20:10
@gilluminate gilluminate merged commit e55d71f into main Oct 15, 2024
13 checks passed
@gilluminate gilluminate deleted the HJ-36-dataset-with-nested-fields branch October 15, 2024 20:58
Copy link

cypress bot commented Oct 15, 2024

fides    Run #10454

Run Properties:  status check passed Passed #10454  •  git commit e55d71f66e: FIX: separate urn with non-nested-pattern for now (#5383)
Project fides
Run status status check passed Passed #10454
Run duration 00m 38s
Commit git commit e55d71f66e: FIX: separate urn with non-nested-pattern for now (#5383)
Committer Jason Gill
View all properties for this run ↗︎

Test results
Tests that failed  Failures 0
Tests that were flaky  Flaky 0
Tests that did not run due to a developer annotating a test with .skip  Pending 0
Tests that did not run due to a failure in a mocha hook  Skipped 0
Tests that passed  Passing 4
⚠️ You've recorded test results over your free plan limit.
Upgrade your plan to view test results.

@Kelsey-Ethyca Kelsey-Ethyca mentioned this pull request Oct 16, 2024
14 tasks
Kelsey-Ethyca pushed a commit that referenced this pull request Oct 16, 2024
Co-authored-by: Lucano Vera <lucanovera@ethyca.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.

2 participants