Skip to content

Fix 471: wrong status code on success - #472

Merged
adutra merged 2 commits into
apache:mainfrom
MonkeyCanCode:fix_471
Nov 27, 2024
Merged

adutra merged 2 commits into
apache:mainfrom
MonkeyCanCode:fix_471

Conversation

@MonkeyCanCode

@MonkeyCanCode MonkeyCanCode commented Nov 25, 2024 •

Copy link
Copy Markdown
Contributor

Description

According to https://polaris.apache.org/in-dev/unreleased/polaris-management-service and https://polaris.apache.org/in-dev/unreleased/rest-catalog-open-api, there are couple endpoints where their success status is 204 instead of 200 (not all of them). As reported by #471, check table existed is one of them where the target status code on success should be 204 instead of 200. While going through IcebergCatalogAdapter.java, I noticed we have couple places where we are using the wrong status code. This PR updated those to reflect the right status code.

Also, there are many places where we are using the following to get status code:

Response.ok(Response.Status.NO_CONTENT).build();

With above, it will always be 200 instead of 204, thus, I changed the code to the following:

Response.status(Response.Status.NO_CONTENT).build();

Fixes #471

Type of change

Please delete options that are not relevant.

  • Bug fix (non-breaking change which fixes an issue)
  • Documentation update
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)
  • This change requires a documentation update

How Has This Been Tested?

Other than our standard test suit, I also used the examples ref by 471:

(venv) ➜  Desktop python3 bootstrap.py
polaris_setup.PolarisManagementServiceClient - DEBUG - Url: http://localhost:8181/api/management/v1/
polaris_setup.PolarisManagementServiceClient - DEBUG - Headers: Headers({'accept': '*/*', 'accept-encoding': 'gzip, deflate', 'connection': 'keep-alive', 'user-agent': 'python-httpx/0.27.2', 'authorization': '[secure]', 'content-type': 'application/json'})
polaris_setup.PolarisManagementServiceClient - DEBUG - POST http://localhost:8181/api/management/v1/catalogs; params None; data {"catalog": {"type": "INTERNAL", "name": "dagster_example_catalog", "properties": {"default-base-location": "file:///tmp/dagster_example_catalog"}, "storageConfigInfo": {"storageType": "FILE"}}}
polaris_setup.PolarisManagementServiceClient - DEBUG - POST http://localhost:8181/api/management/v1/principals; params None; data {"principal": {"name": "dagster"}}
polaris_setup.PolarisManagementServiceClient - DEBUG - POST http://localhost:8181/api/management/v1/principal-roles; params None; data {"principalRole": {"name": "dagster_principal_role"}}
polaris_setup.PolarisManagementServiceClient - DEBUG - POST http://localhost:8181/api/management/v1/catalogs/dagster_example_catalog/catalog-roles; params None; data {"catalogRole": {"name": "orchestration_catalog_role"}}
polaris_setup.PolarisManagementServiceClient - DEBUG - PUT http://localhost:8181/api/management/v1/principals/dagster/principal-roles; params None; data {"principalRole": {"name": "dagster_principal_role"}}
polaris_setup.PolarisManagementServiceClient - DEBUG - PUT http://localhost:8181/api/management/v1/principal-roles/dagster_principal_role/catalog-roles/dagster_example_catalog; params None; data {"catalogRole": {"name": "orchestration_catalog_role"}}
polaris_setup.PolarisManagementServiceClient - DEBUG - PUT http://localhost:8181/api/management/v1/catalogs/dagster_example_catalog/catalog-roles/orchestration_catalog_role/grants; params None; data {"grant": {"type": "catalog", "privilege": "CATALOG_MANAGE_CONTENT"}}
ppolaris_setup - INFO - Connected to catalog dagster_example_catalog
polaris_setup - INFO - Creating namespace air_quality
polaris_setup - INFO - Namespace air_quality created
polaris_setup - INFO - Writing pyiceberg config to /Users/yong/.pyiceberg.yaml
polaris_setup - INFO - Polaris setup complete

(venv) ➜  Desktop python3 table_check.py
204

Checklist:

Please delete options that are not relevant.

  • I have performed a self-review of my code
  • I have commented my code, particularly in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • My changes generate no new warnings
  • If adding new functionality, I have discussed my implementation with the community using the linked GitHub issue

@adutra adutra left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

LGTM. It's sad though that we don't have tests that check these statuses, but 🤷‍♂️

@MonkeyCanCode

Copy link
Copy Markdown
Contributor Author

LGTM. It's sad though that we don't have tests that check these statuses, but 🤷‍♂️

Thanks for the review. Yes, it is. I can raise another PR to close those gaps and add the missing test cases.

@MonkeyCanCode

Copy link
Copy Markdown
Contributor Author

@eric-maynard / @adutra I have the test cases ready. I can either port those changes into current PR or wait for current PR to get merge first. Let me know which route is preferred?

@kevinjqliu kevinjqliu left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

thanks for fixing this! had multiple issues raised with pyiceberg due to this bug

@adutra

adutra commented Nov 27, 2024

Copy link
Copy Markdown
Contributor

@MonkeyCanCode let's merge this one right now, as people have been waiting for this fix. The you can add the test cases in a follow-up PR.

@adutra
adutra merged commit 5250b60 into apache:main Nov 27, 2024
@MonkeyCanCode MonkeyCanCode mentioned this pull request Nov 27, 2024
3 of 10 tasks
@MonkeyCanCode
MonkeyCanCode deleted the fix_471 branch December 12, 2024 04:57
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.

[BUG] Catalog endpoint for 'check if a table exists' returns <200> but should return <204>

4 participants