Hi Martin,

On 26/09/25 9:20 pm, Martin Dosch wrote:
> Dear all,
> 
> the latest upstream release of privatebin-cli [0] always fails the tests
> in the debin build environment:
> 
>> === RUN   TestPaste_MimeTypeInference/Text_file
>>    paste_test.go:317: 
>>              Error Trace:    
>> /build/reproducible-path/privatebin-cli-2.1.1/_build/src/go.gearno.de/privatebin/paste_test.go:317
>>              Error:          
>> "data:application/octet-stream;base64,YXR0YWNobWVudCBjb250ZW50" does not 
>> contain "data:text/plain"
>>              Test:           TestPaste_MimeTypeInference/Text_file
> 
> But when running the tests manually it works:
> 
>> go test .
>> ok   go.gearno.de/privatebin/v2      0.014s
> 
> I had a look at the dependencies, but didn't spot anything suspicious.
> I would highly appreciate if someone could give some hints how to debug
> this.

I checked the code in question which seems to take a mimetype and sets it to 
"application/octet-stream"
only if `mime.TypeByExtension` does not give an output.

```
        if len(p.Attachment) > 0 {
                mimeType := p.MimeType
                if mimeType == "" {
                        ext := filepath.Ext(p.AttachmentName)
                        mimeType = mime.TypeByExtension(ext)
                        if mimeType == "" {
                                mimeType = "application/octet-stream"
                        }
                }
``` 

Looking at your output, it seems to me that for ".txt" extension, this is 
returned empty.
So I wrote this tiny program [1] and ran it inside the unshare chroot and on my 
system.

On my system I got "MIME:  text/plain; charset=utf-8" but on chroot it was 
empty. So it
just seemed like `/etc/mime.types` was missing. Just adding a B-D on 
`media-types` fixes
the problem for me.

I've pushed a corresponding commit to salsa. You might also want to add this to 
Depends or
maybe Recommends on this package.

A quick search shows golang mime package does show that it looks for mimetypes 
with this
file 
https://sources.debian.org/src/golang-1.25/1.25.0-2/src/mime/type_unix.go?hl=28#L28
but I did not dig much into it.

Hope that helps! 


[1]:

package main

import (
        "fmt"
        "mime"
)

func main() {
        ext := ".txt"
        mimeType := mime.TypeByExtension(ext)
        fmt.Println("MIME: ", mimeType)
}


Reply via email to