OPINION: Last week Australia was subjected to the unedifying spectacle of the country's first and second law officers giving opposing evidence before a hostile Senate Committee. The hearing involved its fair share of parliamentary theatrics, but it went far beyond this.

The Attorney-General and the government are playing short-term politics at the expense of long-term good government.

The Senate Committee's immediate task is to investigate the serious allegation that Attorney-General George Brandis misled the Parliament about whether he consulted with Solicitor-General Justin Gleeson before issuing a direction in May around the process for obtaining the Solicitor-General's opinion. The two law officers fiercely disagree whether such consultation occurred.

The committee's inquiry has revealed this disagreement is the tip of an iceberg.

Allegations have emerged that Brandis misled a parliamentary committee last year when he told it the Solicitor-General had advised the government "there is a good prospect" the High Court would uphold the validity of a proposed citizenship-stripping bill. It now appears this advice related to an earlier version, not the substantially amended version that was before Parliament.

It has also emerged that Brandis, as at November last year, had not consulted the Solicitor-General on the government's marriage equality proposals. The attorney-general then pointed to shadow attorney-general Mark Dreyfus' admissions that he had sought opinions from other senior lawyers when he did not agree with the Solicitor-General's advice.

It raises concern about "opinion shopping" –  the worrying practice of shopping around to find a legal opinion that is politically convenient, rather than seeking – and following – the Solicitor-General's advice.

Certainly, the Solicitor-General is not a legal oracle. No legal adviser can claim to be. That is the nature of the law. But treating the Solicitor-General's opinion as the final word of the law on significant legal issues promotes the rule of law. It ensures government follows advice provided by a highly qualified, experienced government lawyer. The Solicitor-General has extensive High Court experience, understands the government's historical positions on matters and has statutory guarantees that protect him or her – at least to some extent – from backlash if the advice is not well received.

The direction, which prevents anyone in government from seeking the Solicitor-General's legal opinion without Brandis' written consent, has been heavily criticised and some argue if it is even lawful. That aside, the Solicitor-General referred to it as a "serious and substantial" threat to the office's independence. Former solicitor-general Gavan Griffith, QC, referenced the image of a "dog on a lead".

But perhaps more concerning was Griffith's statement that the direction may be so demeaning to the office of Solicitor-General that it may, in future, attract "monkeys" to the role.

Any potential demeaning of the office now extends far beyond the direction. While Brandis has been at pains to express his respect for Gleeson's legal acumen and insisted, rather incredulously, that they continue to have a good working relationship, his evidence before the Senate Committee told a different story.

Brandis' first comment to the committee was that he was unaware Gleeson had spoken with the shadow attorney-general during the 2016 caretaker period, and he was "shocked" that Gleeson did not tell him of that fact. The second was a thinly veiled accusation that a letter leaked to journalist Laura Tingle had come from the Solicitor-General's office.

These missives serve as warning shots to future officeholders. It is imperative for government to be able to attract the most qualified lawyers to the post. A Solicitor-General must be able to provide advice with confidence and independence in highly politically charged circumstances.

Brandis appears intent on undermining the respect for the integrity and independence of the current Solicitor-General. In his actions and words, he has failed to see the bigger picture. Every government needs a robustly independent, final legal adviser on whom it can rely with confidence. Anything less fails to serve the government. It may mean government initiatives are more likely to be hosed out in court. It may mean the government is no longer able to rely on the status and respect accorded to the Solicitor-General in public debate.

Brandis has scored a series of spectacular own goals for his government and the Australian people.

Dr Gabrielle Appleby is associate professor of law at UNSW and author of The Role of the Solicitor-General: Negotiating Law, Politics and the Public Interest.

This opinion piece first appeared in The Sydney Morning Herald.