Ever wonder if the State Department knows what it’s doing? You should. Consider the case of Z, a former student of mine.

Born and raised in the United States, Z went to China after graduating from college, intending to teach English and learn Chinese. Several years later, he returned home to enroll in the graduate history program at Boston University, where he focused on U.S.-China relations.

To prepare his dissertation, which required extensive archival research in China, Taiwan, and Hong Kong, Z had applied for and won a prestigious Boren Fellowship. Created by Congress in 1991, the Boren program “focuses on geographic areas, languages, and fields of study deemed critical to U.S. national security.”

The Boren Fellowship comes with strings attached—a requirement “to work for the federal government in the national security arena.” To fulfill that obligation, Z applied for the Foreign Service and passed the State Department’s rigorous selection process. His demonstrated competence in Mandarin, a language that the State Department identifies as “critical,” earned him a high rank on the list of prospective FSO candidates. An appointment seemed likely. Only one step remained: a security clearance.

Late last year, after an exhaustive 570-day long investigation, the State Department granted Z a top-secret clearance.  However, the clearance comes with a proviso that prohibits him from being assigned to China, Taiwan, or Hong Kong.

Now having a security clearance means that an individual is deemed to possess qualities of “loyalty, character, trustworthiness, and reliability” sufficient to warrant access to classified materials. By conferring a top-secret clearance, the State Department judges Z fit according to each of these criteria. That is, it does so except in relation to those jurisdictions where his hard-won expertise and language skills, acquired in part at U.S. taxpayer expense, make him a potentially valuable asset in the first place.

True, at some future date, Z could possibly put his Mandarin to work as U.S. consul in Montevideo. And his insights into past U.S.-China relations might find oblique application to the duties of a second secretary assigned to the American embassy in Monrovia. Yet should that be Z’s fate, his talents will be squandered or at least misused.

In all probability, Z will never make it to Montevideo or Monrovia or anywhere else as an FSO. Hiring China experts ineligible for assignment to China, Taiwan, and Hong Kong does not figure as a State Department priority. So Z now slips back down the order of merit list, his prospects of gaining any appointment whatsoever considerably diminished.

The State Department did not explain its reasons for attaching an asterisk to Z’s security clearance. We may speculate, however, that Z’s marriage to a Chinese woman, occurring six years before he applied to the State Department, figures as one factor. Upon her own graduation from college in 2004, Z’s wife was offered admission to a fully-funded master's degree at a leading Chinese University on the condition that she join the Chinese Communist Party. Then age twenty-one, she did so, becoming one of 85 million members. Her involvement in party activities was never more than nominal, as she subsequently detailed when applying—successfully—for a green card.

Z’s wife is a Communist in the same sense that Donald Trump is a Presbyterian. We do well to distinguish between opportunism and conviction, between what is superficial and what is deeply felt.

Whatever the rationale, the punitive action taken against Z—when it comes to government service, security clearance restrictions are necessarily punitive—fails the test of logic. If on matters Chinese, Z’s “loyalty, character, trustworthiness, and reliability” are suspect, as the caveat attached to his clearance implies, then what is the basis for believing that he will manifest the requisite virtues when addressing matters that relate to Uruguay and Liberia or when filling out a travel voucher?

What we have here is a vestige of the McCarthy era, when presumptions of loyalty gave way to guilt by association. Charged with harboring traitors and subversives, the State Department reacted by cravenly launching a witch hunt. The "CYA" reflex so much in evidence then finds its echo in the handling of Z’s Foreign Service candidacy today.

Z himself will survive this setback and do fine. The State Department’s loss will prove to be the historical profession’s gain.

But the State Department’s loss is also the nation’s loss. The United States needs diplomats who are not only loyal but who also possess a deep understanding of countries like China on which the future wellbeing of our own country will greatly depend. If the Foreign Service can’t find room in its ranks for someone like Z, then its priorities are sadly out of whack.

Andrew J. Bacevich is professor emeritus of history and international relations at Boston University.  His most recent book is America’s War for the Greater Middle East:  A Military History.