• Posts
  • RSS
  • ◂◂RSS
  • Contact

  • Adventures in upstreaming

    June 18th, 2019
    rss, tech  [html]
    In playing with Openring and setting up a page with lots of snippets I noticed that snippets from two Atom feeds were not coming through properly. Looking at the feeds, I saw that they had <content> but no <summary>, and then looking at the source I saw the issue:
    summary := runewidth.Truncate(
      policy.Sanitize(item.Summary),
      summaryLen, "...")
    
    I changed this locally to be:
    raw_summary := item.Summary
    if len(raw_summary) == 0 {
     raw_summary = item.Content
    }
    summary := runewidth.Truncate(
      policy.Sanitize(raw_summary),
      summaryLen, "...")
    
    That is, if a summary is present then use that, otherwise fall back to the content.

    This turns out not to be right, though, because the content can contain escaped HTML tags which we want policy.Sanitize to remove. Something that works, though I'm not sure if it's correct, is:

    raw_summary := item.Summary
    if len(raw_summary) == 0 {
      raw_summary = html.UnescapeString(item.Content)
    }
    summary := runewidth.Truncate(
      policy.Sanitize(raw_summary),
      summaryLen, "...")
    
    This works for me, but the nice thing to do would be to send the patch to the author, right? This turned out to take much longer than I expected.

    I started by going to the project page which is hosted by what seems to be a GitHub competitor written by the same author (Drew DeVault). I was thinking I'd need to download the code, and make a pull request.

    I first had to make an account, which seems reasonable, but then it wanted me to sign up for a paid plan. That wasn't something I was up for, as someone trying to submit a patch, but I did see that it offered an "I just want to contribute, no paid plan please" option and went with that.

    Once I had confirmed my email, though, there wasn't an obvious way to make a pull request. I gave up and decided to email a patch to the author. I ran git format-patch -1 HEAD to package up my most recent commit, and sent that as an attachment.

    Drew wrote back, very promptly and friendly, but saying that they only accept patches sent through the git email protocol. The way git was originally intended to be used, before things got centralized on GitHub, was with specially formatted patches sent through email. If you look at the output of format-patch it's just an email.

    So, ok, I follow the docs at git-send-email.io, also helpfully written by this author, to set up git send-email on the Linux VPS where I was working. I run:

    $ git send-email \
      --smtp-debug=1 \
      --to "~sircmpwn/public-inbox@lists.sr.ht" \
      0001-feeds-with-no-summary.patch
    
    but first it hangs for a long time and then I get:
    Unable to initialize SMTP properly. Check config and use
    --smtp-debug. VALUES: server=smtp.gmail.com encryption=tls
    hello=jefftk.com port=587 at /usr/lib/git-core/git-send-email line
    1383.
    
    Drew helpfully suggested I try telnet to make sure I can connect to smtp.gmail.com on port 587:
    telnet smtp.gmail.com 587
    Trying 74.125.206.109...
    [hangs]
    ^C
    
    I'm running on a tiny VPS at Scaleway, mostly because it's really cheap. I later figured out that Scaleway blocks outgoing SMTP ports by default, to make things less attractive to spammers. They have documentation on how to turn this off, but it's out of date. What I needed to do was go to Instances > Security Groups > Default Security Group and check the "Enable SMTP" box.

    My theory at the time, though, was that Gmail was blocking SMTP from Scalway's IP range, so I decided to try sending email from my laptop.

    This got me a different error:

    Can't locate Net/SMTP/SSL.pm in @INC (you may need to install
    the Net::SMTP::SSL zmodule) (@INC contains: ...)
    
    Fortunately this one was described in the docs, so I ran:
    sudo -H cpan Net::SMTP::SSL IO::Socket::SSL
    
    Unfortunately, sending email now failed with:
    STARTTLS failed! SSL connect attempt failed error:14007086:SSL
    routines:CONNECT_CR_CERT:certificate verify failed at
    /usr/local/git/git-214293479.50/libexec/git-core/git-send-email
    line 1498.
    
    After some searching I found this blog post which mentioned setting smtpsslcertpath. It sounds like either git or perl can't find my root certificate authorities, and so is failing closed? Not the best error message! I added to my .gitconfig:
    smtpsslcertpath = /etc/ssl/cert.pem
    
    And now it worked!

    Overall, this was a lot of work to upstream a simple patch. If I had known at the outset how long it would take I probably would have just sent an email describing the bug and how I thought it could be fixed, and not mention that I had a patch.

    Comment via: facebook

    Recent posts on blogs I like:

    Governance in Rich Liberal American Cities

    Matt Yglesias has a blog post called Make Blue America Great Again, about governance in rich liberal states like New York and California. He talks about various good government issues, and he pays a lot of attention specifically to TransitMatters and our …

    via Pedestrian Observations November 19, 2020

    Collections: Why Military History?

    This week, I want to talk about the discipline of military history: what it is, why it is important and how I see my own place within it. This is going to be a bit of an unusual collections post as it is less about the past itself and more about how we st…

    via A Collection of Unmitigated Pedantry November 13, 2020

    Misalignment and misuse: whose values are manifest?

    Crossposted from world spirit sock puppet. AI related disasters are often categorized as involving misaligned AI, or misuse, or accident. Where: misuse means the bad outcomes were wanted by the people involved, misalignment means the bad outcomes were wan…

    via Meteuphoric November 13, 2020

    more     (via openring)


  • Posts
  • RSS
  • ◂◂RSS
  • Contact