-
-
Notifications
You must be signed in to change notification settings - Fork 3k
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(gateway): undesired conversions to dag-json and friends #9566
Conversation
@lidel another option I see is to completely remove support for |
Let's add a test that ensures we keep read-only support for CIDs with |
@lidel we had the tests already 😃 ( |
4bc5454
to
bbecb93
Compare
This is getting really hairy. I am writing more tests, as I've found some new papercuts and missing cases that we should have regression tests for:
I will prepare a fix and push together with tests. |
- adds bunch of additional tests including JSON file on UnixFS - fix: dag-json codec (0x0129) can be returned as plain json - fix: json codec (0x0200) cna be retrurned as plain json - same for cbor variants
Pushed two fixes and tests in c3ebe80 @hacdias when you start on Friday, take a look at the above changes as a sanity check and lmk if anything is weird or needs to be better commented. (interop/webui tests are failing due to unrelated reason – tracking in #9570) |
@lidel what you pushed works if a file has JSON content (or whatever content it has). However, it does not work for a CID that has the codec JSON (or CBOR for that matter). The fault in the tests lies in that I pushed a fix and another test... I'm also not very happy with this. It's becoming increasingly complex and I feel like there must be a way of simplifying this. I will give it some thought during today's morning and see if I can simplify it somehow. |
Thanks for catching this @hacdias Maybe we could simplify things a bit by adding CID codec check at the end of I will circle back to this PR after meetings, but don't want to block the release, we have test coverage now which is the most important part. We may:
I feel this PR makes it safe to ship in 0.18, but lmk |
@lidel I think we should merge as-is and simplify later if possible. |
I'm good with us doing the followups in the next release (assuming we do the changelog update and have the followup issue for 0.19). Thanks for handling. |
(writing updates to release notes section, will push and merge before Monday) |
* fix(gateway): do not convert unixfs/raw into dag-* unless explicit * fix(gateway): keep only dag-json|dag-cbor handling * fix: allow requesting dag-json as application/json - adds bunch of additional tests including JSON file on UnixFS - fix: dag-json codec (0x0129) can be returned as plain json - fix: json codec (0x0200) cna be retrurned as plain json * fix: using ?format|Accept with CID w/ codec works * docs(changelog): cbor and json on gateway Co-authored-by: Marcin Rataj <lidel@lidel.org>
In the spirit of https://github.com/protocol/bifrost-infra/issues/2290 and ipfs/specs#328 (review), this PR removes implicit conversion from UnixFS/RAW to DAG-* when
json
is requested, and performs the conversion only when explitidag-json
is present in the request.We also fixed handling of CID with
json
andcbor
codecs + added more tests.Weird, unrelated things, are happening in the CI. – tracked in #9570