validate all inputs before associating line_extension

reason: when extension id is invalid, the REST API would return 404,
saying that the context of the extension does not exist. We want a 400
error, saying that the extension is invalid.