Yesterday, I was working on a fix for an issue on Ruby Central’s CFP app. Along the way, I came across this Rails controller file. Here is a simplified version:

1 class CommentsController < ApplicationController

2 def create

3 proposal = Proposal.find(parmas[:proposal_id])

4 proposal.comments.create!(comment_params)

5

6 # Send the user back to where they came from

7 redirect_to :back, info: "Your comment has been added"

8 end

9 end

10

11 private

12 def comment_params

13 params.require(:comment).permit(:body)

14 end

15

If you pay close attention, you may observe that the indentation on line 7 is wrong[1], and the class definition actually ended too early on line 9.

This appears to be a rebase error, an honest mistake that most of us have made at some point (perhaps way too often).

Given how broken it looks (once you have seen the problem), you would not have expected things to work. Perhaps it will explode at load time with a SyntaxError; if you have written some tests, you would probably expect some of them to probably fail too.

However, in this case, everything still “works”. The app boots just fine, and if you try clicking through the UI to post a comment, nothing appears to be broken. Even the tests are passing. (In fact, if you look at the commit message, this change was made specifically to make the tests pass!)

How did that happen?