#000 fix: Pre-render certificate SVG (printUri) so RC serves the filled template - #2
Open
likhithThammegowda wants to merge 2 commits into
Open
#000 fix: Pre-render certificate SVG (printUri) so RC serves the filled template#2likhithThammegowda wants to merge 2 commits into
likhithThammegowda wants to merge 2 commits into
Conversation
…rves the filled template
The RC create flow (generateRequest) only sent the raw templateUrl + a thin
credential (recipientName/trainingName/trainingId). The RC certificate-api
then re-rendered the raw SVG and left every ${...} template variable
unsubstituted (recipientName, courseName, maxScore, rmNumber, issuedDate,
qrCodeImage). The incredible SvgGenerator (which correctly resolves all these
vars via VarResolver#getCertMetaData, including the Aastrika-specific fields)
was never wired into the RC path.
Fix: render the fully-substituted SVG on the generator side and send it as
printUri in the RC create request. Fail-safe: any render/QR error returns ""
and the request degrades to the previous templateUrl-only behaviour.
…ves the filled printUri
The RC-only generator never wrote new certificates to sunbird.cert_registry, so
cert-registry downloadV2 fell to its fallback branch and re-rendered the raw
templateUrl (which cannot fill the incredible ${..} placeholders) -> blank cert.
Restore the old-format write: render the SVG once, reuse it for the RC create
request and POST it to cert-registry /certs/v2/registry/add (id, jsonData.printUri,
accessCode, recipient, related). Download then hits Branch 1 and returns the stored
filled printUri, matching prod. The registry write is non-fatal so issuance is not
blocked on failure. generatePrintUri now also returns the QR accessCode.
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.
Problem
Generated certificates render with unsubstituted
${…}placeholders (${recipientName},${courseName},${maxScore},${rmNumber},${issuedDate},${qrCodeImage}) instead of the actual values.Root cause
CertificateGeneratorFunction.generateRequestsends only the rawtemplateUrl+ a thin credential (recipientName/trainingName/trainingId).sunbird-rc-certificate-apire-renders the raw template and leaves the variables unfilled. The incredible rendererSvgGenerator.generate(resolves all vars viaVarResolver#getCertMetaData, incl. Aastrika fields) was never called in the RC flow.Fix
generatePrintUri(certModel, templateUrl): buildsCertificateExtension, generates QR, callsSvgGenerator.generatefor the fully-substituted SVG.generateRequestsends it asprintUriin the RC create request so RC stores/serves the filled cert.Verify before merge
${…}).printUri(methodgetPrintUri); compare vs a working prod cert record.Single file:
collection-certificate-generator/.../certgen/functions/CertificateGeneratorFunction.scala.