KOEN
All notes
CODE & OPERATIONS

The URL came along with the error

Turning a Go error containing a fake URL into text carried its query value along too. I removed that value and checked what could still be learned about the failure.

A hand covers the tail of a printed diagnostic ticket with a coral sleeve while a magnifying glass keeps its clock and path marks visible

What travelled into the error line

I constructed a Go error with a fake address and printed its string. It ended with context deadline exceeded. Before that came the request address, including recipient=demo-person.

No real person or secret was involved. The address used example.invalid, and demo-person was an invented marker. I sent no HTTP request.

I put the address directly into a url.Error’s URL field and context.DeadlineExceeded into its cause. This did not reproduce a server taking too long to respond; it checked what text this constructed error produced. The run used Go 1.27.0.

I wanted one line describing the failure. Other details attached to the address travelled into the same line.

Go’s url.Error holds an operation, a URL, and an underlying error. The http.Client.Do documentation also describes returned errors as *url.Error. The object contains more than a generic request-failed sentence.

Reading an account of masking queries in error logs prompted the example. I started with the part I could inspect in an error object without making a request.

A value may belong in an outgoing request. Whether everybody reading a failure needs that value is another question.

In my example, removing the recipient marker would still leave a path and the cause used to construct the error. I tried leaving that detail out.

What can still be asked afterward?

I parsed the address, cleared its query, and constructed a new url.Error. I kept Op, the operation, and Err, the cause. The original error stayed unchanged.

The new string retained /report and context deadline exceeded. Neither recipient nor demo-person remained.

Stopping there would let a function that blanked the entire message pass an absence check. I looked for things that should survive too.

Timeout() on the new error returned true. Asking errors.Is whether its cause was context.DeadlineExceeded also returned true. Those checks showed the timeout classification and access to the cause in this example. They did not measure elapsed waiting time.

I liked that distinction. Removing a value from the human-readable message did not require erasing the route by which code could ask about the failure.

This example removed only the URL query. It did not handle values in a path, other address components, or an inner error’s own text. I did not inspect an actual system’s log routing or previously stored records either.

I would not call this a function that can be attached to every log and finish the job. It is a small check of what disappeared from one constructed line and what remained.

If I carried the example into real work, I would put “can I still identify the failure?” beside “has the marker gone?” Somebody still has to read the result.

Back at the error line, the invented recipient marker is absent. Get, /report, and context deadline exceeded remain.

Now I can see both what was hidden and what can still be asked.

Sources

All notes