matrix-org / matrix-org/matrix-hookshot

Tests should test all legal server name formats

Open
#1,000 1 comment 0 reactions 0 assignees View on GitHub

Nobody has claimed this yet.

Dominant language
TypeScript
Stars
450
Forks
95
Avg merge
1d 2h
Merged PRs (30d)
23

Description

I ran into an issue with generic hooks when running Hookshot on localhost with the server name set to `localhost:8448`.

```log
INFO 12:16:27:794 [GenericHookConnection] onGenericHook !QrmxBsBKPajykCohPz:localhost:8448 7e789bf2-7b87-4b10-9438-a22a6f1090d2
ERROR 12:16:27:800 [Appservice] Error registering user: User ID is in use
ERROR 12:16:27:804 [MatrixHttpClient] (REQ-15) {
errcode: 'M_FORBIDDEN',
error: 'Application service cannot masquerade as this user (@_webhooks_hookname:localhost).'
}
WARN 12:16:27:804 [Bridge] Failed to handle generic webhook MatrixError: M_FORBIDDEN: Application service cannot masquerade as this user (@_webhooks_hookname:localhost).
at Object.defaultErrorHandler [as errorHandler] (/usr/bin/matrix-hookshot/node_modules/matrix-bot-sdk/lib/http.js:10:9)
at doHttpRequest (/usr/bin/matrix-hookshot/node_modules/matrix-bot-sdk/lib/http.js:98:31)
at process.processTicksAndRejections (node:internal/process/task_queues:105:5)
at async descriptor.value (/usr/bin/matrix-hookshot/node_modules/matrix-bot-sdk/lib/metrics/decorators.js:19:32)
at async descriptor.value (/usr/bin/matrix-hookshot/node_modules/matrix-bot-sdk/lib/metrics/decorators.js:19:32)
at async GenericHookConnection.ensureDisplayname (/usr/bin/matrix-hookshot/Connections/GenericHook.js:271:13)
at async GenericHookConnection.onGenericHook (/usr/bin/matrix-hookshot/Connections/GenericHook.js:478:13)
at async /usr/bin/matrix-hookshot/Bridge.js:435:25
at async Promise.all (index 0)
at async LocalMQ. (/usr/bin/matrix-hookshot/Bridge.js:410:13) {
body: {
errcode: 'M_FORBIDDEN',
error: 'Application service cannot masquerade as this user (@_webhooks_hookname:localhost).'
},
statusCode: 403,
errcode: 'M_FORBIDDEN',
error: 'Application service cannot masquerade as this user (@_webhooks_hookname:localhost).',
retryAfterMs: undefined
}
```

I proposed a fix to this specific bug in https://github.com/matrix-org/matrix-hookshot/pull/999, but would be nice if tests checked this for all Hookshot features.

Having the port in the server name is legal according to the Spec: https://spec.matrix.org/v1.12/appendices/#server-name

Contributor guide

Open the contributing guide

First steps

  1. Read the whole issue, then the project's contributing guide.
  2. Comment on the issue to say you are picking it up — it saves two people doing the same work.
  3. Fork the repository and make your change on a branch.
  4. Open a pull request that references the issue number.

Research direction

Start by reviewing the generic-hook path identified in the report, including Connections/GenericHook.js, and compare it with proposed fix PR #999. Locate the existing tests for Hookshot features and extend coverage to legal Matrix server-name formats, including localhost:8448; done means all relevant features accept the formats without producing an invalid user ID.

Written by the indexing model from the issue text.

Assessment

Tech stack
typescript
Domain
testing-qa
Issue type
Bug
Difficulty
4/5
Estimated time
3-5 days
Activity status
Stale
Clarity
Mostly clear
Newbie friendliness
25/100

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.