Code generation - missing alternate function with partial USB initialization
I think there is a bug with code generation when USB_OTG_HS_Dx is selected for PA11 and PA12 pins and USB_OTG_HS peripheral is not active:

then there is this code generated in MX_GPIO_Init() function:
/*Configure GPIO pins : PA11 PA12 */
GPIO_InitStruct.Pin = GPIO_PIN_11|GPIO_PIN_12;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
.Mode is set to alternate function but there is missing setting of GPIO_InitTypeDef.Alternate field. In this case, USB is not Alternate function but Additonal function, which means that no configuration is needed here and the USB peripheral manages it itself when it is configured. Indeed, when USB_OTG_HS peripheral is initialized from the GUI, this code disappears. I think this is a bug because in our case, code like this was generated:
/*Configure GPIO pins : PB14 PB15 */
GPIO_InitStruct.Pin = GPIO_PIN_14|GPIO_PIN_15;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_VERY_HIGH;
GPIO_InitStruct.Alternate = GPIO_AF9_SDMMC2;
HAL_GPIO_Init(GPIOB, &GPIO_InitStruct);
...
/*Configure GPIO pins : USB_N_Pin USB_P_Pin */
GPIO_InitStruct.Pin = USB_N_Pin|USB_P_Pin;
GPIO_InitStruct.Mode = GPIO_MODE_AF_PP;
GPIO_InitStruct.Pull = GPIO_NOPULL;
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
so PA11 and PA12 got mapped to FDCAN (alternate function 9 is FDCAN in this case) which collided with the 'real' FDCAN pins and CAN1 did not work at all.
IDE version: 1.15.0

STM32CubeMX version: 6.11.0

MCU: STM32H723ZG
Similar to this thread: https://community.st.com/t5/stm32cubemx-mcus/missing-alternate-function-on-spi-pins-in-cubemx-generated-code/m-p/76662/highlight/true#M1342