  The Hubble diagram is one of the cornerstones of observational cosmology. It
is usually analysed assuming that, on average, the underlying relation between
magnitude and redshift matches the prediction of a
Friedmann-Lema\^itre-Robertson-Walker model. However, the inhomogeneity of the
Universe generically biases these observables, mainly due to peculiar
velocities and gravitational lensing, in a way that depends on the notion of
average used in theoretical calculations. In this article, we carefully derive
the notion of average which corresponds to the observation of the Hubble
diagram. We then calculate its bias at second-order in cosmological
perturbations, and estimate the consequences on the inference of cosmological
parameters, for various current and future surveys. We find that this bias
deeply affects direct estimations of the evolution of the dark-energy equation
of state. However, errors in the standard inference of cosmological parameters
remain smaller than observational uncertainties, even though they reach percent
level on some parameters; they reduce to sub-percent level if an optimal
distance indicator is used.
