
19 Cal.Rptr.3d 436 (2004)
122 Cal.App.4th 1303
The PEOPLE, Plaintiff and Respondent,
v.
Frank KENDRICK, Defendant and Appellant.
No. F044059.
Court of Appeal, Fifth District.
October 4, 2004.
Review Granted January 19, 2005.
*437 Deborah Prucha, under appointment by the Court of Appeal, Woodland, for Defendant and Appellant.
Bill Lockyer, Attorney General, Robert R. Anderson, Chief Assistant Attorney General, Mary Jo Graves, Assistant Attorney General, J. Robert Jibson and Charles Fennessey, Deputy Attorneys General, for Plaintiff and Respondent.

OPINION
VARTABEDIAN, Acting P.J.
The issue before us on this appeal is whether a defendant may validly enter into a plea bargain that permits sentencing under the determinate sentencing law, when the admitted crime is a "nonviolent drug possession offense" for purposes of Proposition 36. (See Pen.Code, §§ 1210, subd. (a), 1210.1.) We conclude he may, and *438 affirm defendant's sentence imposed pursuant to the plea bargain.

Facts and Procedural History
Defendant Frank Kendrick agreed to sell a police informant "3 or 4" ounces of cocaine. The informant met defendant at a Wal-Mart parking lot. Defendant's associate, Delgado, stood watch in front of the store. At the informant's prearranged signal, officers moved in to arrest defendant. They found 3.56 ounces of cocaine under the seat of defendant's car and a much smaller amount in his pocket. As the officers arrested defendant, Delgado turned away and entered a store. Other officers arrested him. A search of Delgado's home recovered 1.59 pounds of cocaine.
An information charged defendant with possession of cocaine for sale (count 1; Health & Saf.Code, § 11351) and transportation of cocaine (count 2; Health & Saf. Code, § 11352, subd. (a)) not for personal use (Pen.Code, § 1210, subd. (a)). The information also contained certain enhancement allegations.
Defendant eventually entered into a plea agreement whereby the prosecutor would amend the information to charge possession of cocaine (Health & Saf.Code, § 11350) and dismiss the other counts and enhancement allegations. Defendant agreed to plead guilty to the amended charge and to receive a sentence not to exceed two years in prison. The agreement also provided for a Cruz waiver (People v. Cruz (1988) 44 Cal.3d 1247, 246 Cal.Rptr. 1, 752 P.2d 439), pursuant to which defendant was released from custody pending imposition of sentence in return for his agreement that the court could impose up to the maximum term of three years in prison on the amended information if defendant failed to abide by the terms of the release agreement.
Defendant failed to abide by the terms of the release agreement. At the sentencing hearing, the court determined defendant was not amenable to probation and was not suitable for referral to California Rehabilitation Center due to excessive criminality. The court found aggravating factors outweighed mitigating factors and imposed the upper term of three years in prison.
Defendant filed a timely notice of appeal. He sought a certificate of probable cause, alleging constitutional ineffectiveness of counsel. The trial court denied the certificate of probable cause.

Discussion

A. Defendant's Contentions
Proposition 36, the Substance Abuse and Crime Prevention Act of 2000, took effect on July 1, 2001. The act, among its other provisions, added sections 1210 (definitions) and 1210.1 to the Penal Code. (All further section references are to the Penal Code, except as indicated.) Section 1210.1 is, when applicable, mandatory: "Notwithstanding any other provision of law, and except as provided in subdivision (b), any person convicted of a nonviolent drug possession offense shall receive probation. As a condition of probation the court shall require participation in and completion of an appropriate drug treatment program. . . ." (§ 1210.1, subd. (a).)
On appeal, defendant claims the court was required to place him on probation for drug treatment pursuant to Proposition 36. Defendant says he was convicted of a nonviolent drug possession offense and, in the absence of disqualifying factors, such probation is mandatory. (See § 1210.1.) He asks that we remand the matter, directing the trial court to place him on Proposition 36 probation.


*439 B. Issues Presented

Defendant sought, and the trial court denied, a certificate of probable cause (on grounds other than those actually raised on the appeal). Section 1237.5 provides that, in most instances, a defendant must obtain a certificate of probable cause in order to challenge a judgment entered on a guilty plea. (See People v. Buttram (2003) 30 Cal.4th 773, 780, 134 Cal.Rptr.2d 571, 69 P.3d 420.) One of the judicially created exceptions to section 1237.5 permits a defendant to challenge on appeal the trial court's exercise of sentencing discretion after a guilty plea, so long as the challenge is not, in effect, a challenge to the "validity of the plea." (Buttram at pp. 781-782, 134 Cal.Rptr.2d 571, 69 P.3d 420.) Similarly, a defendant is not permitted to challenge on appeal an unauthorized sentence prescribed by a plea bargain to which he or she has assented (id. at p. 783, 134 Cal.Rptr.2d 571, 69 P.3d 420), unless acceptance of the plea bargain is beyond the fundamental jurisdiction of the trial court (see People v. Nguyen (1993) 13 Cal.App.4th 114, 121, 16 Cal.Rptr.2d 490).
The dispositive questions on this appeal, therefore, are whether defendant's appeal effectively challenges the validity of the guilty plea and whether the court's acceptance of the plea bargain in this case was in excess of the court's fundamental jurisdiction.

C. Attack on the Validity of the Plea
The Supreme Court has stated that when a sentence is part of the plea bargain, an attack on the sentence is an attack on the validity of the plea and an appeal mounting such an attack must be dismissed absent a certificate of probable cause. (People v. Buttram, supra, 30 Cal.4th at p. 785, 134 Cal.Rptr.2d 571, 69 P.3d 420.) If the appeal attacks only the exercise by the trial court of sentencing discretion reserved to the trial court by the plea agreement, no certificate is required (ibid.); although in such case the defendant must have properly preserved the issue below (which defendant did not do in the present case) (see People v. Scott (1994) 9 Cal.4th 331, 353, 36 Cal.Rptr.2d 627, 885 P.2d 1040).
In this case, the appeal does not challenge the trial court's exercise of the discretion reserved to it in the plea bargain  namely, the exercise of discretion in sentencing under the determinate sentencing law. Instead, appellant claims that the plea bargain granting such discretion in the first instance was invalid and that the court was required by law to sentence defendant under section 1210.1.
We conclude this appeal constitutes an attack on the validity of the plea.[1] Unless the court was lacking in fundamental jurisdiction to sentence pursuant to the plea, the appeal must be dismissed for failure to obtain a certificate of probable cause.

D. The Trial Court's Jurisdiction
When section 1210.1 is applicable and sentence is to be imposed under Proposition 36, a defendant is not permitted to *440 bargain for an inappropriate drug treatment program as a condition of probation: "the purpose of the statute  to rehabilitate  and its mandate  that the court require participation in and completion of an `appropriate' drug treatment program . . .  are frustrated if the court . . . abandons its responsibility and allows the defendant to bargain for treatment that the court expressly expected to fail." (People v. Campbell (2004) 119 Cal.App.4th 1279, 1289, 15 Cal.Rptr.3d 188 [pet. for review filed 8/9/04].)
Unlike most alternative sentencing schemes, however, a defendant is effectively permitted to opt out of the mandatory drug treatment regimen of section 1210.1, subdivision (a), even if he or she is otherwise eligible for sentencing under that section: Subdivision (b) of section 1210.1 provides that the mandatory probation requirement of subdivision (a) is inapplicable to "[a]ny defendant who refuses drug treatment as a condition of probation." (§ 1210.1, subd. (b)(4).) Accordingly, if a defendant elects to not participate in drug treatment, he or she will be sentenced under the determinate sentencing law.
For reasons of public policy, then, a defendant cannot bargain for "inappropriate" drug treatment (People v. Campbell, supra, 119 Cal.App.4th at p. 1290, 15 Cal. Rptr.3d 188), but no similar policy restricts a defendant's ability to forego all drug treatment and be sentenced under the determinate sentencing law, section 1170 et seq. (see § 1210.1, subd. (b)(4)). Because of this distinction embodied in Proposition 36, we conclude a defendant is entitled to enter into a plea bargain by which he agrees to be sentenced under the determinate sentencing law instead of section 1210.1. As a necessary consequence of this conclusion, a trial court does not act in excess of its fundamental jurisdiction by accepting  and imposing sentence pursuant to  a plea bargain that calls for imposition of a sentence under the determinate sentencing law.
On the present record, the most that could be claimed is that the plea bargain was not sufficiently clear that defendant would not be sentenced under section 1210.1. (It was abundantly clear defendant would be sentenced under the determinate sentencing law.) Such a claim of defect in the plea proceedings is exactly the type of claim that requires a certificate of probable cause (see People v. Panizzon (1996) 13 Cal.4th 68, 76, 51 Cal.Rptr.2d 851, 913 P.2d 1061), which defendant failed to obtain. This appeal must be dismissed. (People v. Mendez (1999) 19 Cal.4th 1084, 1096, 81 Cal.Rptr.2d 301, 969 P.2d 146.)

Disposition
The appeal is dismissed for failure to obtain a certificate of probable cause.
WE CONCUR: LEVY and CORNELL, JJ.
NOTES
[1]  This is seen clearly in the nature of the remedy to which defendant would be entitled if the substance of his claim on appeal were correct  that is, if the prison sentence permitted by the plea agreement violated Proposition 36. While defendant claims his remedy would be an order for Proposition 36 probation nothing in the plea bargain contemplated such a windfall. Instead, if defendant were correct, the core purpose of the plea bargain would be frustrated and the appropriate remedy would be to vacate the judgment and the plea bargain, thereby reinstating the original information. (See In re Alvernaz (1992) 2 Cal.4th 924, 942-943, 8 Cal.Rptr.2d 713, 830 P.2d 747.) Thus, defendant's claims on appeal necessarily constitute an attack on the validity of the plea.
