A version of this story was originally published on LinkedIn.

Celestine Omin was accustomed to tackling tough engineering problems. Just not the two that the border agent had put in front of his face — or at least not now, after having spent 24 hours cramped in an economy seat on Qatar Airways.

It was Sunday, Feb. 26, and the 28-year-old software engineer had left his home in Lagos, Nigeria, to come to the United States for the first time. It was a work trip. For the last six months, Omin had been working for Andela, a startup that connects the top tech talent in Africa with employers in the U.S. Andela accepts less than 1 percent of applicants into its program and is backed by Facebook’s Mark Zuckerberg and Priscilla Chan. For this particular role, Omin was helping NYC-based fintech startup First Access create a JavaScript application for emerging markets and had secured a short-term visa.

After landing, Omin waited for 20 minutes and then reached the front of the line, where a Customs and Border Protection officer asked him a series of questions. It was here that Omin realized that the job might be challenging, but getting into America could now be impossible. No one at Andela had prepared him for the new reality.

I was just asked to balance a Binary Search Tree by JFK's airport immigration. Welcome to America. — Celestine Omin (@cyberomin) February 26, 2017

After a few minutes of grilling him about the job, the border agent escorted Omin into a small room and told him to sit down. Another hour passed before a different customs officer came in.

“Your visa says you are a software engineer. Is that correct?” the officer asked Omin in a tone the engineer described as accusatory. When Omin said it was right, the officer presented him with a piece of paper and a pen and told him to answer the following questions:

“Write a function to check if a Binary Search Tree is balanced.” “What is an abstract class, and why do you need it?”

To Omin — who now hadn’t slept in more than 24 hours — the questions seemed opaque and could have multiple answers. While he is a skilled software engineer with more than seven years of experience, Omin later tells me that the questions looked to him like someone with no technical background Googled something like, “Questions to ask a software engineer.”

(The U.S. Customs and Border Protection agency did not respond to multiple requests for comment made by LinkedIn over phone and email by the time this story went to press.)

With no context or guidelines on how to answer the questions, Omin, “too tired to even think,” sat down and tried his best. But when he handed his answers back after about 10 minutes of work, the official told him his answers were wrong. “No one would tell me why I was being questioned,” Omin told me by phone. “Every single time I asked [the official] why he was asking me these questions, he hushed me ... I wasn’t prepared for this. If I had known this was happening beforehand, I would have tried to prepare."

“That is when I thought I would never get into the United States,” he told me with noticeable fear in his voice.

Omin tells me that the answers to the questions were technically correct, but he suspects the customs official interrogating him wasn’t technically trained and couldn’t understand his answers. More time passed, and Omin started to mentally prepare to get on a plane back to Nigeria. Then — with little explanation — the official told him he was free to go.

“He said, ‘Look, I am going to let you go, but you don’t look convincing to me,’” Omin said. “I didn’t say anything back. I just walked out.”

Omin later learned that U.S. Customs allowed him into the country after officials called Andela and First Access to corroborate his story. Jeremy Johnson, the co-founder and CEO of Andela, said that his co-founder Christina Sass was the one to receive the call to defend Omin. Just last year, Andela connected more than 100 technical workers from Africa with short-term work in the U.S. This is the first time that any of them have ever been grilled with questions specific to software engineering or their particular trade.

“Celestine was the first software engineer at one of the most visible e-commerce sites in Africa and is exactly the kind of person we want coming to America and sharing his skills,” said Johnson, who was named to LinkedIn’s Next Wave last year. “Tapping into brilliant minds like Celestine’s is a huge help to many American companies who are struggling to find talent.”

For every web developer looking for work in the U.S., there are roughly five open positions. That’s why startups like Andela exist in the first place: To connect foreign tech workers with opportunities here in the U.S. But now with his partners having a hard time getting into the country to work, Johnson is worried that he might have challenges in the future. He has already reached out to Customs and Border Protection for further clarification on why Omin’s work visa was flagged, but he hasn’t heard back yet.

“We seek to play by the rules, but we can’t respond to rules that are ad hoc,” Johnson said. “We want to make sure that our team members around the world know what to prepare for and don’t get unnecessarily hassled for their work.”

As for Omin, he says the experience hasn’t changed how he feels about the United States. A proud Nigerian who recently became a father, he is eager to continue to use his tech background to create growth for his country. That said, he was initially concerned about going public with his experience because he's worried he'll be added to a watch list of travelers and have trouble entering the U.S. in the future.

“I have been trying to focus here, and I haven’t thought about what is going to happen when I go back to the airport,” he said. “I am coming here legally with good intentions, and I hope to continue this work.”

Chip Cutter contributed reporting to this article.

Caroline Fairchild is the New Economy Editor at LinkedIn. Prior to joining LinkedIn, she served as the founding editor of Fortune's The Broadsheet, and has also reported for the Huffington Post and Bloomberg. Reach her @CFair1.

Subscribe to the Recode Newsletter Sign up for our Recode Daily newsletter to get the top tech and business news stories delivered to your inbox. Go