There was a point in time when municipal bonds were a risk-averse investor's dream come true. Lauded for their tax benefits, municipal bonds have historically been an enticing option for anyone looking to generate a steady income stream with relatively low risk. Throw in the fact that munis are always tax-exempt at the federal level (sometimes at the state level, too), and it's no wonder millions of Americans choose to stake their savings and retirement funds on the success of municipal bonds.

But things aren't all rosy on the muni front. In fact, while history might indicate that municipal bond defaults are a rarity, they have become more frequent since the 2008 financial crisis, and in recent years the muni market has seen its share of negative press. In 2013, Detroit filed bankruptcy in what was the single largest municipal filing to date. Chicago, with its shaky finances and grossly underfunded pension plans, could easily be next. And then there's Puerto Rico, perhaps the biggest ticking time bomb threatening to blow the muni market to bits.

Why Puerto Rico could spell trouble
Puerto Rico is in serious financial trouble. It can't pay its debts and in fact defaulted on a $58 million payment in August 2015. For this reason, it's now pushing for approval to restructure its debt under Chapter 9 of the bankruptcy code, an option afforded to mainland municipalities but not Puerto Rico due its commonwealth status.

While the idea of a municipal debt restructuring is nothing new, what's unique about Puerto Rico is that for the first time in a long time, it's clear that general obligation bonds aren't as sacred as we'd all like to think. General obligation bonds have historically carried significantly lower default rates than revenue bonds, which is a big reason being that they're backed by the full faith and credit of the issuing entity. But now Puerto Rico is talking about restructuring its general obligation bonds and forcing investors to take a haircut in the process, and if it succeeds, it could turn the entire muni market upside-down.

If Puerto Rico's general obligation bondholders do come away with the raw end of the deal, then the resulting discontent could spread into the rest of the muni market, causing even highly rated bonds to suddenly lose value. And when bonds lose value, you're faced with two choices: sell at a loss or hold onto those bonds until they mature while getting smacked upside the head with inflation year after year. Remember, municipal bonds don't just come with credit risk; like all long-term bonds, municipal bonds carry interest rate risk, too, and holding them for 20 years or more could mean losing out on much higher returns elsewhere.

Managing your risk
If you currently hold muni bonds that haven't lost value, then now may be a good time to unload at least some of them, especially if your portfolio is particularly bond-heavy. With talk of the Fed raising rates again in 2016, there's a danger that bond values will decline anyway as a natural consequence. And if Puerto Rico does get away with shortchanging its general obligation bondholders, there's a good chance muni bond values will fall across the board.

Any bonds sold at a loss can be used to offset capital gains, which may be advantageous if you're in a higher tax bracket. Remember, too, that you can deduct up to $3,000 in net losses per filing year. If your net loss exceeds $3,000, then you can carry the remaining loss into 2017 and beyond.

If you're thinking of investing in municipal bonds this year, proceed with caution and do your research. Just as bond-issuing companies are rated for creditworthiness, so are municipalities. The Municipal Securities Rulemaking Board has a neat little service called EMMA (Electronic Municipal Market Access) where you can access a wealth of information, from bond prices to disclosures. Sticking to "A"-rated issuers can lower your risk of winding up on the wrong end of a default.

Of course, a high credit rating will only get you so far if you invest in municipal bonds and then the entire market blows up following whatever news comes out of Puerto Rico in the coming months. It just goes to show that there's no such thing as a risk-free investment, even in a market that was considered overwhelmingly safe not long ago.

Try any of our Foolish newsletter services free for 30 days. We Fools may not all hold the same opinions, but we all believe that considering a diverse range of insights makes us better investors. The Motley Fool has a disclosure policy.