Kodak Black has been behind bars since last month after cops claimed they found illegal drugs on him -- but now, his legal team says lab tests prove ... it was all kosher.
The rapper's attorney, Bradford Cohen, just filed new legal docs -- obtained by TMZ -- asking a judge to dismiss this new drug case against his client ... which alleges Kodak had a controlled substance on him, Oxy, on Dec. 7, and that he was trying to hide it from officers who rolled up on him.
You'll recall ... during the arrest, officers claimed that when they found Kodak that evening -- allegedly asleep at the wheel while parked on a road -- they discovered white powder in his mouth, and went on to allege that KB was trying to hide this from them.
The cops say they tested the substance on the spot -- and alleged that it came back positive for cocaine, so they cuffed Kodak and hauled him off to jail ... where they booked him for possession, evidence tampering, and a traffic violation.
Of course, the authorities also alleged he was in violation of his current probation -- but now, Cohen says the lab tests have come back on the substance ... and they show Kodak wasn't lying when he said the white powder collected that night was just Percocet.
Cohen argues Kodak has a valid prescription for Oxycodone so prosecutors have no grounds to hit him with the drug possession charge.