NEW YORK — Six artificial flavors are being ordered out of the food supply in a dispute over their safety, but good luck to anyone who wants to know which cookies, candies or drinks they’re in.

The dispute highlights the complex rules that govern what goes in food, how much the public knows about it, and a mysterious class of ingredients that has evolved over decades outside of public view.

On food packages, hundreds of ingredients are listed simply as natural flavor or artificial flavor. Even in minute amounts, they help make potato chips taste oniony or give fruit candy that twang.

“The food system we have is unimaginable without flavor additives,” said Nadia Berenstein, a historian of flavor science based in New York.

The flavors are also at the center of a dispute over how ingredients should be regulated.

The U.S. Food and Drug Administration is giving companies two years to purge their products of six artificial flavors — even though the FDA made clear it thinks the ingredients are safe in the trace amounts they are used.

The six artificial flavors in question, with names like methyl eugenol, benzophenone, ethyl acrylate and pyridine, are used to create cinnamon or spicy notes, fruity or minty flavors, or hints of balsamic vinegar.

The FDA and the Flavor and Extract Manufacturers Association, an industry group, did not respond when asked for examples of products the six ingredients are used in.

But they noted in statements that the compounds have natural counterparts in foods like basil, coffee, grapes and peppermint, and that the action does not affect the naturally derived versions.

The FDA said it had to order the artificial versions out of the food supply because of a lawsuit brought by consumer advocacy groups that cited a 60-year-old regulation known as the Delaney clause. The rule prohibits additives shown to have caused cancer in animals, even if tested at doses far higher than what a person would consume.

In a statement, the flavor industry group said the Delaney Clause doesn’t allow regulators to assess an ingredient’s risk based on modern scientific understanding, but that changing it would require an act of Congress. As far back as 1981, the Government Accountability Office issued a report saying the clause should be re-examined because of its inflexibility.

Christopher Kemp, a professor of cancer biology at the Fred Hutchinson Cancer Research Center, doesn’t think the rule is necessarily too strict a threshold. He said animal studies provide the strongest evidence about cancer risk in humans, and that it is better to err on the side of caution.

In a separate but related lawsuit, the FDA is also facing a challenge over its oversight of the universe of ingredients companies can put into foods, including artificial flavors.

New flavors, sweeteners and other ingredients can go through an FDA petition process to be approved as food additives.

But another option lets manufacturers deem their own ingredients to be “generally recognized as safe,” or GRAS.