<SYSTEM_TASK:>
Solve the following problem using Python, implementing the functions described below, one line at a time
<END_TASK>
<USER_TASK:>
Description:
 async def attach_tip(data):
 """ Attach a tip to the current pipette :param data: Information obtained from a POST request. The content type is application/json. The correct packet form should be as follows: { 'token': UUID token from current session start 'command': 'attach tip' 'tipLength': a float representing how much the length of a pipette increases when a tip is added } """

    global session
    tip_length = data.get('tipLength')

    if not tip_length:
        message = 'Error: "tipLength" must be specified in request'
        status = 400
    else:
        if not feature_flags.use_protocol_api_v2():
            pipette = session.pipettes[session.current_mount]
            if pipette.tip_attached:
                log.warning('attach tip called while tip already attached')
                pipette._remove_tip(pipette._tip_length)
            pipette._add_tip(tip_length)
        else:
            session.adapter.add_tip(session.current_mount, tip_length)
            if session.cp:
                session.cp = CriticalPoint.FRONT_NOZZLE
        session.tip_length = tip_length

        message = "Tip length set: {}".format(tip_length)
        status = 200

    return web.json_response({'message': message}, status=status)