The National Book Awards were marred last night when author Daniel Handler (a.k.a. Lemony Snicket), presenting the award for Young People’s Literature to Jacqueline Woodson for her verse memoir “Brown Girl Dreaming,” decided that the occasion was right for him to tell a joke about race and watermelon. He told the audience:

I told you! I told Jackie she was going to win. And I said that if she won, I would tell all of you something I learned this summer, which is that Jackie Woodson is allergic to watermelon. Just let that sink in your mind. And I said you have to put that in a book. And she said, ‘You put that in a book.’ And I said, ‘I am only writing a book about a black girl who is allergic to watermelon if I get a blurb from you, Cornel West, Toni Morrison and Barack Obama saying, “This guy’s okay! This guy’s fine!’ “

Handler’s choice of anecdote demonstrates a poverty of imagination on any number of levels. There is a long-running conversation about a lack of diversity in young adult fiction, the genre in which Handler himself works, which makes Woodson’s win a significant occasion as well as a joyful one. And in an environment that already limits the number of stories about young characters of color, Handler relied on an anecdote that riffed on an exceptionally old stereotype. Rather than celebrating Woodson’s creativity, he found a way to define her by her relationship to old tropes about what black people eat.

The apology Handler issued this morning is not explicitly about that failure to come up with a joke or a story that would spotlight what makes Woodson truly unique, rather than measuring her by a strange, stale metric. But I think it gets at something else important.

“My job at last night’s National Book Awards #NBAwards was to shine a light on tremendous writers, including Jacqueline Woodson,” he tweeted, “and not to overshadow their achievements with my own ill-conceived attempts at humor. I clearly failed, and I’m sorry.”

I think he is right to apologize for drawing attention to himself. What is uncomfortable about this story is not simply that it is about African Americans and watermelon, but that it is an attempt at self-flattery. In the anecdote, Woodson tries to deflect Handler’s suggestion that she should write about her allergy. And in response, Handler tries to show off how racially aware he is.

The man in the story knows that he could not write about the supposed black taste for watermelon without being excoriated as racist. The man telling the story is eager to show off that he knows the limits of what he has the authority to speak about, and what jokes it is okay and not okay for him to make.

I can understand why such an anecdote might have been tempting to relate. It is nice to get credit for being smart and perceptive, or to be reassured that you have handled a difficult situation with grace and sensitivity. But on someone else’s night, it was unwise and inappropriate for Handler to swipe even a little bit of Woodson’s glow, particularly by shoring up his racial bona fides.

In an environment where prominent people’s apologies are often flip, insufficient or even outright distortions of the facts, I am glad to see Handler not just apologizing, but also apologizing for the right thing.