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

Allowlist metadata Import bug #4762

Merged
merged 9 commits into from
May 20, 2020

Conversation

codingkarthik
Copy link
Contributor

@codingkarthik codingkarthik commented May 13, 2020

fixes #4687

Description

Changelog

  • CHANGELOG.md is updated with user-facing content relevant to this PR.

Affected components

  • Server
  • Console
  • CLI
  • Docs
  • Community Content
  • Build System
  • Tests
  • Other (list it)

Related Issues

Solution and Design

Earlier, while importing the metadata, the key expected for allow-list was allow_list and the key used while exporting is allowlist. Due to this mismatch, the allow list was not getting imported.

Solution: Change the key name from allow_list to allowlist.

Steps to test and verify

  1. Add a query to the allowed list
  2. Export the metadata
  3. Import the metadata (earlier, the allow-list was not being imported)

Limitations, known bugs & workarounds

Server checklist

Catalog upgrade

Does this PR change Hasura Catalog version?

  • No
  • Yes
    • Updated docs with SQL for downgrading the catalog

Metadata

Does this PR add a new Metadata feature?

  • No
  • Yes
    • Does run_sql auto manages the new metadata through schema diffing?
      • Yes
      • Not required
    • Does run_sql auto manages the definitions of metadata on renaming?
      • Yes
      • Not required
    • Does export_metadata/replace_metadata supports the new metadata added?
      • Yes
      • Not required

GraphQL

  • No new GraphQL schema is generated
  • New GraphQL schema is being generated:
    • New types and typenames are correlated

Breaking changes

  • No Breaking changes

  • There are breaking changes:

    1. Metadata API

      Existing query types:

      • Modify args payload which is not backward compatible
      • Behavioural change of the API
      • Change in response JSON schema
      • Change in error code
    2. GraphQL API

      Schema Generation:

      • Change in any NamedType
      • Change in table field names

      Schema Resolve:-

      • Change in treatment of null value for any input fields
    3. Logging

      • Log JSON schema has changed
      • Log type names have changed

@codingkarthik codingkarthik requested a review from a team as a code owner May 13, 2020 15:26
@hasura-bot
Copy link
Contributor

Review app for commit 94b828f deployed to Heroku: https://hge-ci-pull-4762.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4762-94b828f9

@codingkarthik codingkarthik changed the title Allowlist metadata bug Allowlist metadata Import bug May 13, 2020
@codingkarthik codingkarthik requested a review from 0x777 May 13, 2020 16:16
Copy link
Contributor

@tirumaraiselvan tirumaraiselvan left a comment

Choose a reason for hiding this comment

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

changelog approved

@hasura-bot
Copy link
Contributor

Review app for commit 38fa300 deployed to Heroku: https://hge-ci-pull-4762.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4762-38fa3006

- it checks if the metadata is the same when created through APIs
  and while importing the metadata into graphql-engine
@netlify
Copy link

netlify bot commented May 14, 2020

Deploy preview for hasura-docs ready!

Built with commit 16cd83c

https://deploy-preview-4762--hasura-docs.netlify.app

@hasura-bot
Copy link
Contributor

Review app for commit 59a0f04 deployed to Heroku: https://hge-ci-pull-4762.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4762-59a0f040

@@ -535,6 +535,10 @@ def test_export_replace(self, hge_ctx):
}
replace_code, replace_resp, _ = hge_ctx.anyq(url, replace_query, headers)
assert replace_code == 200, replace_resp
# The export_resp and export_resp_1 should be the same
Copy link
Member

Choose a reason for hiding this comment

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

It will greatly help to have an explanation on why we are doing this check, the assert export_resp == export_resp_1 already conveys this comment.

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 have added some comments to explain the test.

@hasura-bot
Copy link
Contributor

Review app for commit b81801e deployed to Heroku: https://hge-ci-pull-4762.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4762-b81801e2

# after creating the metadata through the metadata APIs and the metadata
# exported after importing the metdata using the `replace_metadata` to be
# the same. Doing this check, ensures that the metadata has been properly
# imported by the graphql-engine.
Copy link
Member

Choose a reason for hiding this comment

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

This is definitely better but if you think about it, this content

we are again exporting the metadata to assert that the metadata exported
after creating the metadata through the metadata APIs and the metadata
exported after importing the metdata using the replace_metadata to be
the same.

can again be inferred by reading the code easily. What is hard to understand is this part:

Doing this check, ensures that the metadata has been properly
imported by the graphql-engine

I spent a good few minutes trying to understand how this catches the current bug at hand, you are exporting, then importing and then exporting again, why would anything change? The 'why' is the most important part that should go into the comment:

This test catches incorrect key names in export_metadata serialization, for example if allowlist is misspelled as allow_list, the first export metadata would have {..., "allow_list":, ...} but when you import this and export the metadata again, this incorrect key will be absent because replace_metadata doesn't import the incorrectly serialized metadata and therefore there is nothing about allowlist that can be exported the second time and hence the two exports will differ.

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 have changed the comment a bit

This test catches incorrect key names(if any) in the export_metadata serialization, for example, A new query collection is added to the allow list using the add_collection_to_allowlist metadata API. When
the metadata is exported it will contain the allowlist. Now, when this
metadata is imported, if the graphql-engine is expecting a different key
like allow_list(instead of allowlist) then the allow list won't be imported. Now, exporting the metadata won't contain the allowlist key
because it wasn't imported properly and hence the two exports will differ.

Let me know, what you think

Copy link
Member

@0x777 0x777 left a comment

Choose a reason for hiding this comment

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

LGTM

Verified

This commit was created on GitHub.com and signed with GitHub’s verified signature. The key has expired.
@hasura-bot
Copy link
Contributor

Review app for commit 4d858dc deployed to Heroku: https://hge-ci-pull-4762.herokuapp.com
Docker image for server: hasura/graphql-engine:pull4762-4d858dcc

@codingkarthik codingkarthik merged commit ac30767 into hasura:master May 20, 2020
@hasura-bot
Copy link
Contributor

Review app https://hge-ci-pull-4762.herokuapp.com is deleted

hgiasac pushed a commit to hgiasac/graphql-engine that referenced this pull request May 29, 2020
fix bug which was not allowing the allowlist to be imported
shahidhk pushed a commit that referenced this pull request May 29, 2020
fix bug which was not allowing the allowlist to be imported
stevefan1999-personal pushed a commit to stevefan1999-personal/graphql-engine that referenced this pull request Sep 12, 2020
fix bug which was not allowing the allowlist to be imported
karthikvt26 pushed a commit to karthikvt26/graphql-engine that referenced this pull request Nov 17, 2020
fix bug which was not allowing the allowlist to be imported
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.

allowList property omitted during application of metadata snapshot
4 participants