def patch(httpreq: Request, request: PatchDFIQRequest, id: str) -> dfiq.DFIQTypes:
    """Modifies an DFIQ object in the database."""

    if request.dfiq_object and request.dfiq_yaml:
        raise HTTPException(
            status_code=400,
            detail="Cannot provide both dfiq_object and dfiq_yaml in the request",
        )

    if not request.dfiq_object and not request.dfiq_yaml:
        raise HTTPException(
            status_code=400,
            detail="Either dfiq_object or dfiq_yaml must be provided in the request",
        )

    db_dfiq: dfiq.DFIQTypes = dfiq.DFIQBase.get(id)  # type: ignore
    if not db_dfiq:
        raise HTTPException(status_code=404, detail=f"DFIQ object {id} not found")

    if request.dfiq_yaml:
        try:
            update_data = dfiq.TYPE_MAPPING[db_dfiq.type].from_yaml(request.dfiq_yaml)
        except ValueError as error:
            raise HTTPException(
                status_code=status.HTTP_400_BAD_REQUEST, detail=str(error)
            )

    if request.dfiq_object:
        update_data = request.dfiq_object

    if db_dfiq.type != update_data.type:
        raise HTTPException(
            status_code=400,
            detail=f"DFIQ type mismatch: {db_dfiq.type} != {update_data.type}",
        )
    db_dfiq.get_acls()
    updated_dfiq = db_dfiq.model_copy(
        update=update_data.model_dump(exclude=["created"])
    )
    new = updated_dfiq.save()
    new.get_acls()
    audit.log_timeline(httpreq.state.username, new, old=db_dfiq)
    new.update_parents()

    if request.update_indicators and new.type == dfiq.DFIQType.question:
        dfiq.extract_indicators(new, user=httpreq.state.user.username)

    return new
Modifies an DFIQ object in the database.
core/web/apiv2/dfiq.py