OPINION
POMEROY, Justice.On March 20, 1974, appellant, Emmanuel Beatty, pleaded guilty to charges of robbery and aggravated assault and battery. He was sentenced on June 4, 1974 to a term of not less than four nor more than ten years imprisonment. Beatty filed a timely appeal from the judgment of sentence to the Superior Court, but on the advice of counsel Beatty later withdrew the appeal and simultaneously filed a petition under the Post Conviction Hearing Act, Act of January 25, 1966, P.L. (1965) 1580, § 1 et seq., 19 P.S. § 1180-1 et seq. (Supp.1976-1977) [hereinafter “the Act” or “PCHA”].1 Appellant’s petition was dismissed by the PCHA court without an evidentiary hearing. On appeal from the dismissal, a majority of the Superior Court affirmed, holding that Beatty’s withdrawal of his prior direct appeal constituted a waiver, under section 4(b)(1) of the Act,2 of his right to challenge collaterally the lawfulness of his guilty plea. Commonwealth v. Beatty, 236 Pa.Super. 137, 344 A.2d 591 (1975). This Court then granted allocatur to determine whether appellant was entitled to an evidentiary hearing on his claim. For the reasons set forth below, we vacate the orders of the Superior Court and the PCHA court, and remand the case to the court of common pleas for such a hearing.
Section 9 of the PCHA provides:
*107“If a petition alleges facts that if proven would entitle the petitioner to relief, the court shall grant a hearing which may extend only to the issues raised in the petition or answer. However, the court may deny a hearing if the petitioner’s claim is patently frivolous and is without a trace of support either in the record or from other evidence submitted by the petitioner.” 19 P.S. § 1180-9 (Supp.1976-1977).
In accordance with this provision this Court has held that a PCHA petition may be summarily dismissed if the facts alleged in the petition would not, even if proved, entitle the petitioner to relief.3 E. g., Commonwealth v. O'Donnell, 472 Pa. 25, 370 A.2d 1209 (1977); Commonwealth v. Hargrove, 434 Pa. 393, 254 A.2d 22 (1969).
In this case, the PCHA petition alleged in effect that Beatty’s guilty plea was unlawfully induced by assurances by his trial counsel that upon being sentenced appellant would not be incarcerated, but instead would receive a civil commitment under section 410 of the Mental Health and Mental Retardation Act, Act of October 20, 1966, Special Sess. No. 3, P.L. 98, Art. IV, § 410, 50 P.S. § 4410 (Supp. 1976-1977). In our view, this claim is not “patently frivolous” within the meaning of section 9 of the Act. See Blackledge v. Allison, 431 U.S. 63, 97 S.Ct. 1621, 52 L.Ed.2d 136 (1977); cf. Commonwealth v. Sanutti, 454 Pa. 344, 312 A.2d 42 (1973); Commonwealth v. Alvarado, 442 Pa. 516, 276 A.2d 526 (1971). Since appellant’s claim depends upon proof *108of facts outside the record his right to relief can be established only through an evidentiary hearing. He is entitled to such a hearing, however, only if he has not waived his right to challenge collaterally the validity of his plea. The Superior Court having held that a waiver occurred, we must consider the correctness of that ruling.
Central to the Superior Court’s conclusion that a waiver occurred was its determination that appellant could and should have attacked his guilty plea on direct appeal.4 Our recent cases, however, have corrected whatever misapprehension may have existed on this score. It is now settled that the proper procedure for attacking a guilty plea following the entry of judgment of sentence is to file with the trial court which accepted the plea a petition to withdraw the plea. Commonwealth v. Zakrzewski, 460 Pa. 528, 333 A.2d 898 (1975); Commonwealth v. Lee, 460 Pa. 324, 333 A.2d 749 (1975); Commonwealth v. Starr, 450 Pa. 485, 301 A.2d 592 (1973).5 See also Commonwealth v. Bunch, 466 Pa. 22, 351 A.2d 284 (1976) (opinion announcing decision of the Court); Commonwealth v. Robinson, 442 Pa. 512, 276 A.2d 537 (1971).6 But see Commonwealth v. Tunnell, 463 Pa. 462, 345 *109A.2d 611 (1975); Commonwealth v. Fields, 463 Pa. 244, 344 A.2d 814 (1975); Commonwealth v. Hines, 461 Pa. 271, 336 A.2d 280 (1975). Since its decision in the case at bar the *110Superior Court has itself held that a defendant may not attack the validity of a guilty plea on direct appeal without first filing a petition to withdraw the plea with the trial court. Commonwealth v. Roberts, 237 Pa.Super. 336, 352 A.2d 140 (1975). The purpose of this procedure was well-stated by Judge Cercone:
“The same principles which mandate that issues not raised in post-verdict motions will not be considered on direct appeal mandate that an attack on a guilty plea on direct appeal must be preceded by the filing of a petition to withdraw such plea with the court below. The enforcement of this procedure will give the court which accepted the plea the opportunity to allow the withdrawal of the plea if it was in fact not voluntarily and understanding^ made. If the defendant remains unsatisfied with the lower court’s disposition of his petition to withdraw his guilty plea, then at that point the issue would be properly preserved and ripe for appellate review. Strict adherence to this procedure could, indeed, preclude an otherwise costly, time consuming, and unnecessary appeal to this court.” Id. 237 Pa.Super. at 338-39, 352 A.2d at 141.
See also Commonwealth v. Rodgers, 465 Pa. 379, 384, 350 A.2d 815, 818-19 (1976) (Pomeroy, J. concurring, joined by Manderino, J.).
Since guilty pleas are properly attacked in the first instance in the trial court, it follows that appellant cannot be faulted for failing to attack his plea on direct appeal. To hold otherwise would create the anomaly of penalizing appellant for failing to follow a procedure now recognized as incorrect.7
*111The order of the Superior Court affirming the dismissal of appellant’s PCHA petition is vacated, the order of the court of common pleas is vacated, and the record is remanded to the court of common pleas for proceedings consistent with this opinion.
ROBERTS, J., filed a concurring opinion. EAGEN, C. J., and NIX and MANDERINO, JJ., concur in the result.. Appellant’s present counsel is different from trial counsel but is the same lawyer who both initially advised appellant to appeal to the Superior Court and then advised withdrawing the appeal in favor of filing a PCHA petition. According to appellant’s brief, the reason for withdrawing the initial appeal was present counsel’s belief that an issue which lacked a proper factual foundation could not properly be raised on direct appeal.
. Section 4(b)(1) of the PCHA provides in relevant part that an issue is waived for purposes of the Act if “[t]he petitioner knowingly and understanding^ failed to raise it and it could have been raised . . onappeal '. . . .” 19P.S. § 1180-4(b)(l) (Supp.1976-1977).
. The authority to dismiss is restricted in two situations: (1) where a petitioner asserts that he is indigent and requests appointment of counsel, the court must first determine the fact of indigency, and if necessary, appoint counsel to assist in an amendment of the petition. See Pa.R.Crim.P. 1503(a), 19 P.S. § 1180-12 (Supp.1976-1977); Commonwealth v. Adams, 465 Pa. 389, 350 A.2d 820 (1976); (2) if the petition is deficient by reason of failure to allege specific facts, section 7 of the Act, 19 P.S. § 1180-7 (Supp.1976-1977), mandates that the petitioner be given an opportunity to amend the petition so as to remedy that lack of particularity.
The above exceptions to the dismissal prerogative of the court are inapplicable in this case since appellant was represented by counsel, and his petition was sufficiently particular to preclude summary dismissal.
. In reaching, this conclusion, the Superior Court relied upon Commonwealth v. Dancer, 460 Pa. 95, 331 A.2d 435 (1975) and Commonwealth, v. Twiggs, 460 Pa. 105, 331 A.2d 440 (1975). This reliance was misplaced. These cases involved claims of ineffective assistance of counsel and held that, with certain exceptions not here relevant, ineffectiveness claims should be raised on direct appeal. In contrast, as will be observed in the text infra, claims of invalid guilty pleas are properly brought in the trial court in the first instance.
. In Commonwealth v. Zakrzewski, supra, and Commonwealth v. Lee, supra, the appellants directly appealed to this Court without first filing petitions to withdraw their pleas in the trial court. We addressed the merits of appellants’ claims despite the incorrect procedure because of prior confusion concerning the correct procedure to follow and because the appellants were attacking the validity of the guilty plea colloquy itself which was of record. In contrast, appellant’s attack in the case at bar does not concern the adequacy of the colloquy, but alleges the existence of facts not of record.
. This procedure for attacking guilty pleas after sentence has been imposed, with minor differences in the terminology used in the cases, was recently implemented in rule form by means of a new Rule of *109Criminal Procedure, Pa.R.Crim.P. 321, adopted June 29, 1977, effective September 1, 1977. This rule provides:
“RULE 321. CHALLENGE TO GUILTY PLEA OR LEGALITY OF SENTENCE ON GUILTY PLEA.
“(a) A motion challenging the validity of a guilty plea, the legality of a sentence on a guilty plea or the denial of a motion to withdraw a guilty plea shall be in writing and shall be filed with the trial court within ten (10) days after imposition of sentence.
“(b) The motion shall be disposed of promptly.
“(c) The trial court may schedule a hearing on the motion and shall determine whether the motion shall be argued before one judge alone or before a panel of judges sitting as a court en banc. Whenever a single judge hears the motion alone, the judge may make any ruling that could be made by a court en banc.
“NOTE: Prior Rules 321 and 322 combined into new Suspension Rule 340, and new Rule 321 adopted June 29, 1977, effective September 1, 1977.
COMMENT
“This rule parallels the procedure under Rule 1123, relating to post-verdict motions following trials.
“This rule affords a procedure whereby a challenge to the validity of a guilty plea, to the legality of a sentence on a guilty plea, or to the denial of a motion to withdraw a guilty plea (under Rule 320), must be made in the first instance in the trial court, thereby giving that court the first opportunity to correct any error asserted. If the case proceeds to an appellate court, this procedure also provides a full record concerning such matters. Under appellate practice, only issues so raised are considered on appeal. Cf. Commonwealth v. Lee, 460 Pa. 324, 333 A.2d 749 (1975); Commonwealth v. Roberts, 237 Pa.Super. 336, 352 A.2d 140 (1975); Commonwealth v. Hunter, 240 Pa.Super. 23, 360 A.2d 702 (1976).
“The procedure set forth in this rule is separate and distinct from withdrawal of a plea prior to sentence (see Rule 320). Cf. Standards Relating to Pleas of Guilty § 2.1(a)(ii), A.B.A. PROJECT ON MINIMUM STANDARDS FOR CRIMINAL JUSTICE (Approved Draft, 1968).
“For related procedures to be followed by a judge sentencing a defendant on a plea of guilty, see Rule 1405(c).
“The words ‘trial court’ are intended to refer to the judge who presided at the challenged proceeding. Most often, the plea judge and the sentencing judge will be the same; the motion would then be heard by that judge. In some cases, however, the plea judge and the sentencing judge may be different, and a motion challenging the validity of the plea or the jurisdiction of the court to hear the plea would expectably be referred to the plea judge, while a motion challenging the legality of a sentence would expectably be referred to the sentencing judge.
*110“Under the Pennsylvania Rules of Appellate Procedure (Pa.R. A.P. 343), the time for filing an appeal commences on the date of the final order deciding the motion. It is anticipated that the trial court will make every effort to speedily dispose of motions under this rule, so that the appeal time will not be tolled indefinitely.
“A denial of a motion to withdraw a guilty plea under Rule 320 may not be appealed until such denial has first been challenged under this rule.”
. While Beatty was correct in withdrawing his appeal to the Superior Court, his attack on his guilty plea should have been made by filing *111at the trial court level a petition for leave to withdraw his plea rather than through a PCHA petition. Notwithstanding this technical procedural mistake on appellant’s part, however, we perceive no reason why he should not now be allowed to file a correct petition with the trial court.