Update behaviour of ?case=original
query to /service/javascript-app
- return raw contents
#6813
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Resolves #6733.
A sensible use case of
/gov/javascript-app
is to check that the stored app matches the bundle you submitted. As noted in #6433, we can't do a direct equality check on this, because we've recased the response fields to match the Azure API standards. We added a?case=original
field, which falls back to the macro-generatedto_json
conversion.However, as #6733 notes this is still imprecise - the generated C++ conversion function omits some fields if they match default values, so doesn't necessarily return every field from the original bundle. We could try explicitly writing every field (in the classic/original case), but would then be potentially returning more fields than were specified in the original bundle, which would still prohibit a direct equality check.
Instead, this PR uses a raw handle to access the metadata table, and returns that value without any magic parsing conversions. So it matches exactly the bundle that was written by the constitution, with minimal further attempts in C++ to re-serialise/parse/validate this.
There are a few caveats even with this approach:
nlohmann::json
object in C++, to simplify serialisation into the HTTP reponse body. This means we're checking that the C++ JSON parser thinks it is valid JSON, and re-ordering fields within objects.app.json
), and module paths are prefixed with/
(for historical, potentially unjustified, reasons).These caveats mean that even with all this we still can't do a direct equality check - you can't assert that the response to
GET /gov/service/javascript-app?case=original
matches the contents ofapp.json
. But I think this is as close as we can get.