Skip to content

Commit

Permalink
[stream-metadata] additional logging for invalid spaceAddress (#827)
Browse files Browse the repository at this point in the history
  • Loading branch information
tak-hntlabs authored Aug 20, 2024
1 parent dd941a9 commit 70678cc
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 5 deletions.
6 changes: 1 addition & 5 deletions packages/stream-metadata/src/node.ts
Original file line number Diff line number Diff line change
Expand Up @@ -67,11 +67,7 @@ function setupRoutes() {
)
server.get('/space/:spaceAddress/image', fetchSpaceImage)

// Generic / route to return 404
server.get('/', async (request, reply) => {
request.log.info(`GET /`)
return reply.code(404).send('Not found')
})
// Fastify will return 404 for any unmatched routes
}

/*
Expand Down
4 changes: 4 additions & 0 deletions packages/stream-metadata/src/routes/spaceImage.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,17 +12,21 @@ export async function fetchSpaceImage(request: FastifyRequest, reply: FastifyRep
const { spaceAddress } = request.params as { spaceAddress?: string }

if (!spaceAddress) {
logger.info('spaceAddress parameter is required')
return reply
.code(400)
.send({ error: 'Bad Request', message: 'spaceAddress parameter is required' })
}

if (!isValidEthereumAddress(spaceAddress)) {
logger.info({ spaceAddress }, 'Invalid spaceAddress format')
return reply
.code(400)
.send({ error: 'Bad Request', message: 'Invalid spaceAddress format' })
}

logger.info({ spaceAddress }, 'Fetching space image')

let stream: StreamStateView | undefined
try {
const streamId = makeStreamId(StreamPrefix.Space, spaceAddress)
Expand Down

0 comments on commit 70678cc

Please sign in to comment.