As it probes why Boeing’s Starliner spacecraft suffered a serious setback during a flight test last month that forced the cancellation of its planned docking with the International Space Station, NASA faces a high-stakes dilemma: Should the space agency require the company to repeat the uncrewed test flight or allow the next flight to proceed, as originally planned, with astronauts aboard?

The answer could have significant ramifications for the agency — and put astronauts’ lives on the line — at a time when NASA is struggling to resume human spaceflight from the United States, years after the space shuttle fleet was retired in 2011.

Forcing Boeing to redo the test flight without anyone aboard would be costly, possibly requiring the embattled company, already struggling from the consequences of two deadly crashes of its 737 Max airplane, to spend tens of millions of dollars to demonstrate that its new spacecraft is capable of meeting the space station in orbit.

But if NASA moved ahead with the crewed flight and something went wrong that put the astronauts in danger, the agency would come under withering criticism that could plague it for years.

For now, NASA is moving cautiously. It has formed an independent team with Boeing to examine what went wrong with the Starliner during last month’s test flight. NASA also is reviewing data to help it determine whether the capsule achieved enough objectives during its truncated flight to assure NASA that its astronauts will be safe.

On Dec. 20, an Atlas V rocket lifted off from Cape Canaveral, Fla., delivering the Starliner into space. But soon after it was on its own, the Starliner suffered a software problem — its onboard clock was 11 hours off. As a result, the engines that would have put it on a trajectory to the space station failed to fire, even while other thrusters, designed to keep the capsule stable, did fire, expending precious fuel.

Boeing officials regained control of the spacecraft and were able to complete several objectives, including maneuvering the capsule, having it communicate with the space station and deploying the docking system to see whether it would work in a real scenario. But the spacecraft had consumed too much fuel to make it to the space station, and officials canceled that part of the mission.

Two days after it launched, the Starliner landed safely in the New Mexico desert, days ahead of schedule, and officials from NASA and Boeing went out of their way to highlight the things that went well during the mission.

“We’re all very excited that a whole lot of things did go right — went very, very well, as a matter of fact,” NASA Administrator Jim Bridenstine said after the landing. “In fact, you could argue that some of the hardest parts of this mission have now been proven to be very capable.”

But he said the teams would have to figure out what went wrong before allowing crews aboard. Docking with the space station is a delicate endeavor and a key part of the program, which is designed to give NASA a way to get its astronauts there and back safely.

“I’m not saying we’re going to do it. But I’m not ruling it out, either,” Bridenstine said of proceeding with a crewed flight. “Remember, when we had space shuttles, every single one of those missions was crewed from Day One. The very first time we launched space shuttle it had people on board. … These are not things that are new to NASA. But I want to make sure we understand what the challenges were and get those fixed and make sure there’s not some larger, systemic problem.”

Getting NASA’s astronauts flying from American soil again is a huge priority for the agency — and the White House. Bridenstine said that in the 48 hours after the mishap, he spoke three times with Vice President Pence, who heads the National Space Council.

In a blog post, Bridenstine said that the investigation to determine what caused the timing malfunction could take about two months and that a separate determination on whether Boeing would have to re-fly the test mission should be competed in several weeks.

Some industry officials said they think Boeing already has a clear sense of what happened and will be able to fix it without much difficulty.

“Actually what happened and how to fix it is pretty straightforward, and already almost done,” said Wayne Hale, a former manager of NASA’s space shuttle program who now serves as a consultant to many aerospace companies, including Boeing. “The question is — is there anything else out there?”

Another industry official who was not authorized to comment publicly said it is unlikely the setback will be a “showstopper.”

If NASA does force Boeing to perform another test flight, it is not clear who would have to pay the tens of millions of dollars such a mission would cost.

NASA’s contract with Boeing is a “fixed-price contract,” meaning the payments to Boeing are contingent on hitting certain milestones and the amount of those payments should not change. Boeing’s contract with NASA specifically says it “shall include an uncrewed orbital test flight” to the International Space Station that demonstrates “automated rendezvous and proximity operations and docking with the ISS, assuming ISS approval.”

NASA has said that Boeing proposed the uncrewed test flight as a “way to meet NASA’s mission and safety requirements.” As a result, the docking became part of the contract, NASA said. But in his blog post, Bridenstine said it was possible that requirement could be waived. “Although docking was planned, it may not have to be accomplished prior to the crew demonstration,” he wrote. “Boeing would need NASA’s approval to proceed with a flight test with astronauts on board.”

Bridenstine did not say who would be required to pay if NASA ordered the additional uncrewed test flight, an issue that remains unsettled. “Any contractual implications would be informed by the in-depth review and analysis of the data obtained from the company’s uncrewed Orbital Flight Test,” NASA spokesman Joshua Finch said in an email. “NASA and Boeing would determine what additional data is required and the optimal approach for obtaining it. We expect this process to take several weeks.”

NASA officials have said that if astronauts had been aboard Boeing’s spacecraft last month, they could have taken manual control of the spacecraft and flown it safely to the space station. “You could almost say that it might have been better if there had been a crew on board,” Hale said.

For the first flight with crews, NASA has chosen a pair of former military test pilots, astronauts Nicole Mann and Mike Fincke. Joining them would be former NASA astronaut Chris Ferguson, who now works for Boeing. Between them, Fincke and Ferguson have been to space six times, and the trio has years of experience flying all sorts of military aircraft.

“You couldn’t have a better crew for the mission,” Scott Kelly, the former NASA astronaut who spent nearly a year in space during a 2015-2016 mission, said in an interview. “Their capability to fly this flight is not in question. … It wouldn’t surprise me at all if they flew the next flight with people on it.”

Last year, SpaceX, the other company contracted by NASA to fly astronauts to the space station, successfully docked its Dragon crew spacecraft with the station. The company’s cargo spacecraft has visited the space station about 20 times since 2012, delivering experiments and supplies. SpaceX is scheduled to test the Dragon crew craft’s emergency abort system this month and hopes to fly astronauts within a few months.

NASA knows how difficult and dangerous human spaceflight is. In 1986, it lost the crew of space shuttle Challenger, and seven astronauts were killed in 2003 when Columbia came apart before landing. Calculating the risks is particularly difficult on a new spacecraft such as the Starliner.