A file reference is an id, and nothing here forms an address - #97
Merged
Conversation
Four answers named a file only by where to fetch it. The id is what the Client already uses everywhere else; the address follows in a later step, once nothing reads it.
Four interpolations of `/api/v1/files/{id}` are gone with the field. A
face reaching the reader as a reference is what the theme test now says,
because that is what it does.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Four answers named a file by where to fetch it —
AttachmentDto,ProblemFileDto,InstanceLogoDto,InstanceFontDto— each carrying/api/v1/files/<id>, relative to this Server's own origin.That is correct for the Server and wrong in every
<img src>that receives it:an application served from anywhere else asks itself for the bytes and is
answered with its single-page shell,
200 text/htmlwhere a PNG was wanted. Thefigures in four imported statements were blank, and nothing anywhere said why.
The five shapes that already carried a
fileId—StatementRefDto,SubmissionFileDto,ActivityDocumentRefDto,InstanceDocumentRefDto,InstanceThemeDto— were never affected. That is why a statement's textrendered on the same page as its blank figure: the text is fetched by id.
What changes
Those four carry
FileIdand noUrl, and the four$"/api/v1/files/{…}"interpolations go with it. The Server forms no fileaddress at all, so the question of what origin one is relative to does not
arise.
Projections.AttachmentandManagedVersionlose the parameter theytook for it.
Input DTOs are untouched —
NewStatementDto,NewProblemFileDto,NewProblemPackageDtoand the instance inputs have always named afileId, andan address in a request would be a second name for a thing that has one.
Two commits on purpose: the first adds
FileIdbesideUrl, which isadditive and breaks nothing; the second removes
Url. Pairs withAlgoJudge/AlgoJudge-Client#… , which reads the id.
One thing this fixes that was not the subject
ProblemServicehad a second call site passing_ => nullfor the address, so amanager who had just published a version received a file list with no
addresses at all and the preview said the files were not stored. Both call
sites now answer with the id.
Verification
dotnet build -warnaserrorclean, 823 tests pass,openapi.jsonregenerated from the container.
Two tests changed with the contract, and one of them was named for it:
A_declared_face_reaches_the_reader_as_an_addressis now…_as_a_reference, and asserts both halves — thefileIdis the file, andthere is no
urlproperty at all.Measured on a live stack (
AlgoJudge-Clientbeside this Server, thedemonstration bundle imported through the manager's import screen): all four
statement figures answer
200 image/pngwith a decoded width, fetched from theServer's own origin. Measured again on the production topology — a page on
algojudge.testdrawing fromapi.algojudge.test, two hostnames on oneregistrable domain, as
algojudge.appandapi.algojudge.appwill be — and allfour drew there too.