Section 17. Any person aggrieved by a decision of the board of appeals or any special permit granting authority or by the failure of the board of appeals to take final action concerning any appeal, application or petition within the required time or by the failure of any special permit granting authority to take final action concerning any application for a special permit within the required time, whether or not previously a party to the proceeding, or any municipal officer or board may appeal to the land court department, the superior court department in which the land concerned is situated or, if the land is situated in Hampden county, either to said land court or, superior court department or to the division of the housing court department for said county, or if the land is situated in a county, region or area served by a division of the housing court department either to said land court or superior court department or to the division of said housing court department for said county, region or area, or to the division of the district court department within whose jurisdiction the land is situated except in Hampden county, by bringing an action within twenty days after the decision has been filed in the office of the city or town clerk. If said appeal is made to said division of the district court department, any party shall have the right to file a claim for trial of said appeal in the superior court department within twenty-five days after service on the appeal is completed, subject to such rules as the supreme judicial court may prescribe. Notice of the action with a copy of the complaint shall be given to such city or town clerk so as to be received within such twenty days. The complaint shall allege that the decision exceeds the authority of the board or authority, and any facts pertinent to the issue, and shall contain a prayer that the decision be annulled. There shall be attached to the complaint a copy of the decision appealed from, bearing the date of filing thereof, certified by the city or town clerk with whom the decision was filed.
If the complaint is filed by someone other than the original applicant, appellant or petitioner, such original applicant, appellant, or petitioner and all members of the board of appeals or special permit granting authority shall be named as parties defendant with their addresses. To avoid delay in the proceedings, instead of the usual service of process, the plaintiff shall within fourteen days after the filing of the complaint, send written notice thereof, with a copy of the complaint, by delivery or certified mail to all defendants, including the members of the board of appeals or special permit granting authority and shall within twenty-one days after the entry of the complaint file with the clerk of the court an affidavit that such notice has been given. If no such affidavit is filed within such time the complaint shall be dismissed. No answer shall be required but an answer may be filed and notice of such filing with a copy of the answer and an affidavit of such notice given to all parties as provided above within seven days after the filing of the answer. Other persons may be permitted to intervene, upon motion. The clerk of the court shall give notice of the hearing as in other cases without jury, to all parties whether or not they have appeared. The court shall hear all evidence pertinent to the authority of the board or special permit granting authority and determine the facts, and, upon the facts as so determined, annul such decision if found to exceed the authority of such board or special permit granting authority or make such other decree as justice and equity may require. The foregoing remedy shall be exclusive, notwithstanding any defect of procedure or of notice other than notice by publication, mailing or posting as required by this chapter, and the validity of any action shall not be questioned for matters relating to defects in procedure or of notice in any other proceedings except with respect to such publication, mailing or posting and then only by a proceeding commenced within ninety days after the decision has been filed in the office of the city or town clerk, but the parties shall have all rights of appeal and exception as in other equity cases.
A city or town may provide any officer or board of such city or town with independent legal counsel for appealing, as provided in this section, a decision of a board of appeals or special permit granting authority and for taking such other subsequent action as parties are authorized to take.
Costs shall not be allowed against the board or special permit granting authority unless it shall appear to the court that the board or special permit granting authority in making the decision appealed from acted with gross negligence, in bad faith or with malice.
Costs shall not be allowed against the party appealing from the decision of the board or special permit granting authority unless it shall appear to the court that said appellant or appellants acted in bad faith or with malice in making the appeal to the court.
The court shall require nonmunicipal plaintiffs to post a surety or cash bond in a sum of not less than two thousand nor more than fifteen thousand dollars to secure the payment of such costs in appeals of decisions approving subdivision plans.
All issues in any proceeding under this section shall have precedence over all other civil actions and proceedings.