LOS ANGELES — After her son, Eric, was killed by the police in Los Angeles two years ago when officers mistook a water pistol he was holding for a real gun, Valerie Rivera channeled her grief into activism. She joined Black Lives Matter and lobbied the State Legislature to open to the public California’s records on police shootings, which have long been hidden.

She wanted, she recently wrote in a court filing, to “understand what really happened, and to advocate for change so that officers do not kill civilians, and are held accountable when they do, so that other families do not have to suffer as mine has.”

Her efforts paid off. Under a new state law, Ms. Rivera and other members of the public can now request to see the investigative records, prying open for the first time California’s strict secrecy laws regarding police shootings and serious misconduct by officers.

But, just as activists and state lawmakers have sought to bring decades-old investigative records to light, police unions have tried to jam the door shut. While police departments have said they would comply, police unions up and down the state, including in Los Angeles, have filed lawsuits challenging the law, arguing that it shouldn’t be applied retroactively. The union lawsuits have succeeded in some jurisdictions in getting temporary stays from the court.