Section 39J. Notwithstanding any contrary provision of any contract for the construction, reconstruction, alteration, remodeling, repair or demolition of any public building or public works by the commonwealth, or by any county, city, town, district, board, commission or other public body, when the amount of the contract is more than five thousand dollars in the case of the commonwealth and more than two thousand dollars in the case of any county, city, town, district, board, commission or other public body, a decision, by the contracting body or by any administrative board, official or agency, or by any architect or engineer, on a dispute, whether of fact or of law, arising under said contract shall not be final or conclusive if such decision is made in bad faith, fraudulently, capriciously, or arbitrarily is unsupported by substantial evidence, or is based upon error of law.