[Feature] More context for "node not found" error #940

Closed
opened 2025-12-29 02:26:30 +01:00 by adam · 8 comments
Owner

Originally created by @ChibangLW on GitHub (Feb 10, 2025).

Use case

While digging through the logs I noticed a lot of ERR user msg: node not found code=404 log entries. With some different log settings (level: trace, database.debug: true, database.gorm.parameterized_queries: false, database.gorm.skip_err_record_not_found: false) I narrowed it down to a node with a valid nodekey but not in the database. But still no further information about what node it could be.

Description

It would be beneficial to have some more context in the error message.

Contribution

  • I can write the design doc for this feature
  • I can contribute this feature

How can it be implemented?

If not mistaken the error originates in the noise handler. Depending on the log level maybe some more information could be put into the error message or as a seperate trace entry, e.g. dumping the HostInfo object which should be also included in the MapRequest.

Is this something you would accept?

Originally created by @ChibangLW on GitHub (Feb 10, 2025). ### Use case While digging through the logs I noticed a lot of `ERR user msg: node not found code=404` log entries. With some different log settings (`level: trace, database.debug: true, database.gorm.parameterized_queries: false, database.gorm.skip_err_record_not_found: false`) I narrowed it down to a node with a valid nodekey but not in the database. But still no further information about what node it could be. ### Description It would be beneficial to have some more context in the error message. ### Contribution - [ ] I can write the design doc for this feature - [x] I can contribute this feature ### How can it be implemented? If not mistaken the error originates in the [noise handler](https://github.com/juanfont/headscale/blob/b3fa16fbdaf47fe3854b4b306dc6fe7a3d7fbd10/hscontrol/noise.go#L213). Depending on the log level maybe some more information could be put into the error message or as a seperate trace entry, e.g. dumping the HostInfo object which should be also included in the MapRequest. Is this something you would accept?
adam added the enhancementstale labels 2025-12-29 02:26:30 +01:00
adam closed this issue 2025-12-29 02:26:30 +01:00
Author
Owner

@ffuhrnew commented on GitHub (Feb 13, 2025):

I get the same error ERR user msg: node not found code=404 in the log. Installed in a docker container. Error came up after upgrade form version 0.23 directly to version 0.25. How can I fix the cause for the logged error?

@ffuhrnew commented on GitHub (Feb 13, 2025): I get the same error ERR user msg: node not found code=404 in the log. Installed in a docker container. Error came up after upgrade form version 0.23 directly to version 0.25. How can I fix the cause for the logged error?
Author
Owner

@nblock commented on GitHub (Feb 14, 2025):

I get the same error ERR user msg: node not found code=404 in the log. Installed in a docker container. Error came up after upgrade form version 0.23 directly to version 0.25. How can I fix the cause for the logged error?

It looks like a node is talking with headscale but is no longer part of the database.

This message can be easily trigged with headscale nodes delete -i ID for a node that is currently connected.

@nblock commented on GitHub (Feb 14, 2025): > I get the same error ERR user msg: node not found code=404 in the log. Installed in a docker container. Error came up after upgrade form version 0.23 directly to version 0.25. How can I fix the cause for the logged error? It looks like a node is talking with headscale but is no longer part of the database. This message can be easily trigged with `headscale nodes delete -i ID` for a node that is currently connected.
Author
Owner

@ffuhrnew commented on GitHub (Feb 14, 2025):

The Code that brings up the error message seems to be located here: b3fa16fbda/hscontrol/noise.go (L208)
From here on i get no further ...

ns.nodeKey = mapRequest.NodeKey

node, err := ns.headscale.db.GetNodeByNodeKey(mapRequest.NodeKey)
if err != nil {
	if errors.Is(err, gorm.ErrRecordNotFound) {
		httpError(writer, NewHTTPError(http.StatusNotFound, "node not found", nil))
		return
	}
	httpError(writer, err)
	return
}
@ffuhrnew commented on GitHub (Feb 14, 2025): The Code that brings up the error message seems to be located here: https://github.com/juanfont/headscale/blob/b3fa16fbdaf47fe3854b4b306dc6fe7a3d7fbd10/hscontrol/noise.go#L208 From here on i get no further ... ns.nodeKey = mapRequest.NodeKey node, err := ns.headscale.db.GetNodeByNodeKey(mapRequest.NodeKey) if err != nil { if errors.Is(err, gorm.ErrRecordNotFound) { httpError(writer, NewHTTPError(http.StatusNotFound, "node not found", nil)) return } httpError(writer, err) return }
Author
Owner

@kradalby commented on GitHub (Feb 21, 2025):

I do not think you should read into this as an error. It essentially just means that a node that isnt register is trying to connect.
It is equivalent to a user that is not in the database trying to log in (at least in europe where that is a 404).

Should we log it? hard to say, it might be confusing as an error, but it is equivalent to failed login attempts which might be interesting.

@kradalby commented on GitHub (Feb 21, 2025): I do not think you should read into this as an error. It essentially just means that a node that isnt register is trying to connect. It is equivalent to a user that is not in the database trying to log in (at least in europe where that is a 404). Should we log it? hard to say, it might be confusing as an error, but it is equivalent to failed login attempts which might be interesting.
Author
Owner

@github-actions[bot] commented on GitHub (May 23, 2025):

This issue is stale because it has been open for 90 days with no activity.

@github-actions[bot] commented on GitHub (May 23, 2025): This issue is stale because it has been open for 90 days with no activity.
Author
Owner

@github-actions[bot] commented on GitHub (May 31, 2025):

This issue was closed because it has been inactive for 14 days since being marked as stale.

@github-actions[bot] commented on GitHub (May 31, 2025): This issue was closed because it has been inactive for 14 days since being marked as stale.
Author
Owner

@paralin commented on GitHub (Oct 14, 2025):

I agree this should be more detailed.

@paralin commented on GitHub (Oct 14, 2025): I agree this should be more detailed.
Author
Owner

@rittycat commented on GitHub (Nov 20, 2025):

I noticed this issue while doing large scale device tests (starting 600+ tailscale clients in one go) while determining if tailscale is suitable for our usecase.

It does make it difficult to debug what the actual problem is.

As an aside, I feel like Github Actions closing the issue as "Not planned" because it went stale is not ideal?

@rittycat commented on GitHub (Nov 20, 2025): I noticed this issue while doing large scale device tests (starting 600+ tailscale clients in one go) while determining if tailscale is suitable for our usecase. It does make it difficult to debug what the actual problem is. As an aside, I feel like Github Actions closing the issue as "Not planned" because it went stale is not ideal?
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: starred/headscale#940