filed a dissenting statement
in which KEASLER, J., joined.DISSENTING STATEMENT
Andre Derosier was charged by felony indictment with six counts of indecency with a child by contact. On the second day of trial in the 367th District Court of Denton County, Derosier entered into a plea agreement with the State, agreeing to plead no contest to the misdemeanor offense of terroristic threat. The 367th District Court granted the State’s motion to amend the indictment. The terroristic threat count was added as the seventh charged offense. The State then dismissed the first six felony counts. The 367th District Court found Derosier guilty of terroristic threat and sentenced him to one day in jail and credited him with one day of time served.
Twelve years later, claiming collateral consequences, Derosier filed ah application for writ of habeas corpus pursuant to Article 11.09 seeking relief from his misdemeanor conviction. Derosier alleged that the judgment was void because the district court lacked subject matter jurisdiction. The trial court denied the writ application, concluding that, even though the judgment was “void,” Derosier was not entitled to collaterally attack it because he had “enjoyed the benefits of an agreed judgment prescribing a too-lenient punishment.”
On direct appeal, the appellate court agreed with Derosier that the trial court did not have subject matter jurisdiction and reversed the trial court’s judgment. The appellate court’s opinion makes the following assertions supported by case law: (1) A challenge to subject matter jurisdiction can be raised at any time;1 (2) Subject matter jurisdiction cannot be conferred by agreement of the parties, but must be vested in a court by constitution or statute;2 (3) Estoppel does not apply if the trial court had no subject matter juris*502diction;3 and (4) When a trial court lacks jurisdiction, no conviction is possible.4
The State filed a petition for discretionary review alleging one ground: If a defendant agrees to plead to a lesser offense, that is not actually a lesser included offense of an indicted offense over which the trial court has proper subject matter jurisdiction, can a defendant later attack that bargained-for judgment based on a subject matter jurisdiction claim? Today, this Court refuses the State’s Petition for Discretionary Review. I understand this Court’s decision, given that the appellate court’s opinion was well-reasoned and based on precedent from this Court. However, the outcome is not consistent with the intentions of the parties at the time of the plea agreement.
At the writ hearing, Derosier’s counsel informed the trial court that, as part of the plea bargain agreement, “the State agreed to dismiss all of the counts of the indictment after they amended the indictment to put in a misdemeanor charge, which they classified as a lesser included of the indictment.” Derosier’s counsel asserted that, because the “terroristic threat is not a lesser-included offense of indecency with a child or sexual assault of a child, ... the district court did not have jurisdiction over the misdemeanor offense.” The part of the record related to the plea agreement reflects that the parties had originally agreed that Derosier would plead to the lesser included offense of assault; however, at some point, “assault” was crossed out and “terroristic threat” was handwritten on the plea documents. It appears, therefore, that the State had intended to charge a misdemeanor that would not have stripped the district court of subject matter jurisdiction.
In Kirkpatrick v. State, this Court held that an indictment that is defective may nevertheless vest jurisdiction in the district court if it charges an offense and one could fairly conclude from the face of the charging instrument that the State intended to charge a felony or a misdemeanor for which the district court has jurisdiction.5 A court does not lose subject matter jurisdiction once it attaches to a case.6 Here, the court had jurisdiction over the felony charges that were originally indicted, and would have had jurisdiction over a misdemeanor that would have been a lesser-included offense to the charged felonies. If it is clear that the parties intended that the misdemeanor offense charged would be a lesser included offense, it is possible that Kirkpatrick would apply here.
I have additional questions that stem from the State’s ground for review. For example, although total lack of subject matter jurisdiction cannot be waived, would this general principle entitle Derosier to greater relief than simply correction of the jurisdictional defect? 7 The appellate court’s opinion does not clarify what the outcome for Derosier should be. Is he entitled to an acquittal of the misdemeanor charge, or should the case be remanded to the trial court so that an information can be prepared and the case could be trans*503ferred to a county court? Does the statute of limitations apply to the originally indicted offenses, or has it been tolled? Ex parte Heilman indicates that a limitations defense could have been waived under circumstances such as these.8
Moreover, while it is true that subject matter jurisdiction appears to be immune to estoppel considerations, perhaps that is an interpretation that should be changed under circumstances such as these. “Es-toppel is a flexible doctrine that manifests itself in various forms that are not limited to unilateral requests.”9 In Rhodes v. State, “estoppel by judgment” involves a party “who accepts the benefits of a judgment, decree, or judicial order,” and who then is “estopped to deny the validity or propriety thereof.”10 Our opinion in Heil-man extols the virtues and benefits of arm’s length plea agreements made in good faith: “Allowing for such wide-ranging plea agreements benefits not only the defendant and the State, who are free to explore a full array of stipulations and conditions in plea negotiations, but also the courts, whose dockets are thinned by parties ready and willing to settle.” 11 Thus, although our current precedent does not recognize that subject matter jurisdiction can be created by estoppel,12 if there were ever a set of facts that would justify the creation of an exception to this rule, I find them to be present here.
Finally, Derosier’s habeas application was required to show both a cognizable irregularity and harm. An applicant demonstrates harm with proof that the error contributed to his conviction or punishment.13 In this case, the “error” that “contributed to his conviction” is the State’s amendment of the indictment and dismissal of all of the felonies. However, this “invited error” bettered Derosier’s position.
I would grant the State’s petition so that these issues could be addressed by the parties and, ultimately, by this Court. Therefore, respectfully, I dissent to the Court’s refusal of the State’s Petition For Discretionary Review.
. See Ex parte Sledge, 391 S.W.3d 104, 107-08 (Tex. Crim. App. 2013) (holding that jurisdiction may "always” be raised in an original habeas application subject to statutory bars on subsequent applications).
. State v. Roberts, 940 S.W.2d 655, 657 (Tex. Crim. App. 1996), overruled on other grounds by State v. Medrano, 67 S.W.3d 892, 894 (Tex. Crim. App. 2002).
. Rhodes v. State, 240 S.W.3d 882, 891 (Tex. Crim. App. 2007) ("The only exception to this principle [estoppel by judgment] is for challenges to the subject-matter jurisdiction of the court rendering the judgment.”); Ex parte Heilman, 456 S.W.3d 159, 167 (Tex. Crim. App. 2015).
. Heilman, 456 S.W.3d at 168.
. 279 S.W.3d 324, 328-29 (Tex. Crim. App. 2009).
. Trejo v. State, 280 S.W.3d 258, 261 (Tex. Crim. App. 2009) (quoting Bruce v. State, 419 S.W.2d 646, 647 (Tex. Crim. App. 1967)).
. See, e.g., Puente v. State, 71 S.W.3d 340, 343 (Tex. Crim. App. 2002).
. 456 S.W.3d at 162.
. Murray v. State, 302 S.W.3d 874, 882 (Tex. Crim. App. 2009) (quoting Rhodes, 240 S.W.3d at 891).
. Id.
. Heilman, 456 S.W.3d at 167.
. Rhodes, 240 S.W.3d at 891; Heilman, 456 S.W.3d at 167.
. Ex parte Parrott, 396 S.W.3d 531 (Tex. Crim. App. 2013).