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

chore: remove feedback records which are beyond retention policy #2766

Merged
merged 3 commits into from
Feb 9, 2024

Conversation

Mike-Heneghan
Copy link
Contributor

@Mike-Heneghan Mike-Heneghan commented Feb 8, 2024

What

  • Delete feedback records which were created before the retention policy date
  • Rename development -> local for Slack warnings

Why

  • feedback can contain personally identifiable information so needs to be sanitised or deleted
  • Records older than 28 days are likely to have little value and wou;d already have been downloaded and processed
  • The development name is easy to conflate with staging i.e. our .dev environment
  • Renaming to Local explicits shows there's been a failure running sanitisation based on local environment

Screenshot

Rename
Screenshot 2024-02-08 at 16 36 18

Testing

  • Added feedback records and manually changed the dates in the hasura console
  • When cron job triggered the expected records were deleted successfully

@Mike-Heneghan Mike-Heneghan requested a review from a team February 8, 2024 16:37
Copy link

github-actions bot commented Feb 8, 2024

🤖 Hasura Change Summary compared a subset of table metadata including permissions:

Updated Tables (1)

  • public.feedback permissions:

    insert select update delete
    api
    2 added column permissions
    insert select update
    api ➕ created_at
    ➕ id

@Mike-Heneghan Mike-Heneghan force-pushed the mh/feedback-post-retention-deletion branch from 2e9b95b to 1e9d355 Compare February 8, 2024 16:41
@@ -247,6 +247,10 @@ const getFormattedEnvironment = (): string => {
const pizzaNumber = new URL(process.env.API_URL_EXT!).href.split(".")[1];
environment += ` ${pizzaNumber}`;
}
// For readability redefine development as local for slack warnings
if (environment === "development") {
environment = "local";
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Context:

I didn't expect to see a Slack message when my local test of running the sanitisation failed. I think the message was very useful but my first (incorrect) instinct was that I'd triggered something in a live environment.

I was relieved when I saw "Development" although with it being the end of the day and being tired and I did wonder if it was referring to staging and if I'd misunderstood the .env setup for the webhook.

Realistically I don't think I'll make this mistake again and I'm happy to leave this as "Development" if there are any strong opinions.

Copy link
Contributor

Choose a reason for hiding this comment

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

Local is more explicitly not staging, this is fine by me! All for lowering stress / blood pressure 😂

Copy link

github-actions bot commented Feb 8, 2024

Removed vultr server and associated DNS entries

- Add deleteFeedback operation
- Grant delete and select permissions of the feedback table to the API
- Update Hasura test with new permissions
@Mike-Heneghan Mike-Heneghan force-pushed the mh/feedback-post-retention-deletion branch from 1e9d355 to 9705b7f Compare February 8, 2024 17:04
@Mike-Heneghan Mike-Heneghan self-assigned this Feb 8, 2024
const {
feedback: { returning: result },
} = await $api.client.request<{ feedback: Result }>(mutation, {
retentionPeriod: getRetentionPeriod(),
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Comment

I erroneously looked at the getRetentionPeriod from pay: editor.planx.uk/src/lib/pay.ts which is 28 days 🤦

At the top of the file it has the period as 6 months.

I'm wondering whether we stick to 6 months to be consistent with the rest of the sanitisation or swap it to 28 days as originally planned?

Copy link
Contributor

Choose a reason for hiding this comment

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

Yep no problems here - the simpler the better 👍

Let's make sure we communicate this to George / August / Silvia and update Notion to now reflect the changes made in this PR - https://www.notion.so/opensystemslab/Data-Retention-Policy-fcd47af2a8244888b544a1e9c92c88f8

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Great shout! I didn't think to look for a data policy on Notion. The other place is https://www.planx.uk/privacy and Alastair has advised I should give him a shout when the broader feature is ready and he'll update this.

Another place would be the flow setting level privacy policy potentially.

Copy link
Contributor

@DafyddLlyr DafyddLlyr left a comment

Choose a reason for hiding this comment

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

One small comment / question, but happy for this to go ahead as-is.

I've added a checkbox to the Trello ticket to ensure we remember to update our Data Retention Policy on Notion. This could actually be done now, or after we strip out Feeback Fish.

@@ -247,6 +247,10 @@ const getFormattedEnvironment = (): string => {
const pizzaNumber = new URL(process.env.API_URL_EXT!).href.split(".")[1];
environment += ` ${pizzaNumber}`;
}
// For readability redefine development as local for slack warnings
if (environment === "development") {
environment = "local";
Copy link
Contributor

Choose a reason for hiding this comment

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

Local is more explicitly not staging, this is fine by me! All for lowering stress / blood pressure 😂

const {
feedback: { returning: result },
} = await $api.client.request<{ feedback: Result }>(mutation, {
retentionPeriod: getRetentionPeriod(),
Copy link
Contributor

Choose a reason for hiding this comment

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

Yep no problems here - the simpler the better 👍

Let's make sure we communicate this to George / August / Silvia and update Notion to now reflect the changes made in this PR - https://www.notion.so/opensystemslab/Data-Retention-Policy-fcd47af2a8244888b544a1e9c92c88f8

Comment on lines +83 to +97
test("can query feedback", () => {
expect(i.queries).toContain("feedback");
});

test("cannot create, update, or delete teams", () => {
expect(i).toHaveNoMutationsFor("feedback");
test("cannot update feedback", () => {
expect(i.mutations).not.toContain("update_feedback");
expect(i.mutations).not.toContain("update_feedback_by_pk");
});

test("can delete feedback", async () => {
expect(i.mutations).toContain("delete_feedback");
});

test("cannot insert feedback", async () => {
expect(i.mutations).not.toContain("insert_feedback");
Copy link
Contributor

Choose a reason for hiding this comment

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

Thanks for picking this up 👍

@@ -248,6 +248,29 @@
- user_context
- user_data
comment: Allow users who want to leave feedback on their experience to write to the table
select_permissions:
Copy link
Contributor

@DafyddLlyr DafyddLlyr Feb 9, 2024

Choose a reason for hiding this comment

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

nit/question: Are these select permissions needed for the mutation DeleteFeedback to work? It looks like we might need id for the returning clause but no more? Genuinely unusure on this one - this could be correct and I just have a hazy memory of how this works 😅

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ahahahaha I also wasn't sure about this 😅

I added the full column permissions when I was having issues. I couldn't seem to get a straight answer from the docs and I saw that other sanitised tables had the full select permission.

I can work this out by restricting access and testing it not that the feature is working.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks again for picking up on this @DafyddLlyr I kind of wanted to do this testing but was worried I'd been taking too long on this piece of work. So it was a great excuse to try it out!

As discussed it seems the delete requires select permissions for any columns it references i.e. created_at for the where and id for the return value.

I've updated the permissions to reflect this: b259adc

@Mike-Heneghan Mike-Heneghan merged commit 15af1b0 into main Feb 9, 2024
12 checks passed
@Mike-Heneghan Mike-Heneghan deleted the mh/feedback-post-retention-deletion branch February 9, 2024 14:02
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