How do you fix the Azure DevOps Error: Secrets cannot contain multiple lines?

When using the SecretsManagerGetSecret task in Azure DevOps, to retrieve a secret from AWS Secrets Manager, you may encounter the following error message:

task: SecretsManagerGetSecret@1
Reading value for secret 'secret-name'.
##[error]Error: Secrets cannot contain multiple lines

Looking in Secrets Manager in the AWS Console will not reveal the problem.
Everything will look fine, even when viewing the secret in plain text mode.

To see the cause of the error, we need to use the following command to retrieve the secret in its raw form:

aws secretsmanager get-secret-value --secret-id <value>

You will see an output similar to the below:

"SecretString": "{\r\n \"some-key\": some-value\",\r\n}" ..<snip>

Notice the \r\n characters, which were not visible in the Secrets Manager plain text mode.

To fix, remove the secrets and re-add them, ensuring you do not copy any control characters.

AWS CLI: secretsmanager get-secret-value
Docs: AWS Secrets Manager Get Secret
GitHub: SecretsManagerGetSecret@1