fix(activation-service): stop leaking internal errors, drop unused KYC_PUBLIC_KEY - #1109
Merged
Merged
Conversation
…llers The error middleware computed http-errors' `expose` flag and then ignored it. Both branches of the NODE_ENV check sent the message regardless: lodash's `omit(err, ['stack'])` copies `message` through, so the "production" path replied with things like a decoded chain error next to `expose: false`, and the development path — the default, since NODE_ENV is set in neither the Dockerfile nor the chart — added the stack trace on top. Concretely, a request that failed because the funding account was empty replied with `Insufficient Balance Error: Failed to apply 'transfer' on section 'balances' with args '<address>,1000000.` Verified against the built image. Now the flag decides: 4xx keeps its message, because the caller sent something unusable and needs to know what; 5xx returns the generic status text and the real error goes to the log only. Responses are consistently JSON, where a non-http error used to fall through to `res.send(err.message)` as text. NODE_ENV no longer changes what is returned, so a deployment cannot leak by omitting it — which is what every deployment does today.
`KYC_PUBLIC_KEY` has been in bin/www's required env variables since the service was written, but nothing reads it: the signature verification was commented out years ago, and its only caller — `POST /activation/create-entity` — was removed in #1103 as an unauthenticated route that signed a fee-paying extrinsic from the service wallet. A variable that is required but unused only gives the service a reason to refuse to start. Removed from the required list, the chart, and the documented .env. Re-add it alongside the verification code if KYC checks come back. While in the readme, two claims that no longer hold: it documented the removed `/activation/create-entity` endpoint, and said activation "puts 500 tokens" on an account — the amount at the time, since reduced by three orders of magnitude.
sameh-farouk
force-pushed
the
fix/activation-service-error-exposure
branch
from
July 26, 2026 15:51
6c90479 to
b902ddf
Compare
This was referenced Jul 26, 2026
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.
Two follow-ups from #1105. Supersedes #1107, which GitHub auto-closed when #1105 merged and its branch — #1107's base — was deleted. Same content, rebased onto
development.1. Internal error messages were returned to callers
The error middleware computed http-errors'
exposeflag and then ignored it. Both branches of theNODE_ENVcheck sent the message anyway, because lodash'somit(err, ['stack'])copiesmessagethrough:And the development branch — the default, since
NODE_ENVis set in neither the Dockerfile nor the chart — sent the whole error including the stack trace. Every deployment has been running in that mode.Verified against the built image before the fix: a request that failed because the funding account was empty replied with
Insufficient Balance Error: Failed to apply 'transfer' on section 'balances' with args '<address>,1000000.Now the flag decides:
NODE_ENVno longer affects what is returned, so a deployment cannot leak by omitting it — which is what every deployment does today.Behaviour change: bodies are consistently
{ message }. 4xx previously also carriedstatus,statusCodeandexpose; non-http errors fell through tores.send(err.message)as text rather than JSON. The frontend catches errors and renders a fixed string without reading the body, so there is no UI impact.2.
KYC_PUBLIC_KEYwas required but unreadIn
bin/www's required env variables since the service was written, but nothing reads it: the signature verification was commented out years ago and its only caller,POST /activation/create-entity, was removed in #1103 as an unauthenticated route that signed a fee-paying extrinsic from the service wallet. Requiring an unused variable only gives the service a reason to refuse to start.Removed from the required list, the chart and the documented
.env. Re-add it alongside the verification code if KYC checks return.While in the readme, two claims that no longer held: it documented the removed
/activation/create-entityendpoint, and said activation "puts 500 tokens" on an account — true in 2021, since reduced by three orders of magnitude.Verification
Internal Server Errorwhile the underlying error still reaches the log, service boots with noKYC_PUBLIC_KEYset, SIGTERM exits 0🤖 Generated with Claude Code
https://claude.ai/code/session_011YKJm3zuWdSepriT9KL9zy