Adding an external HTML link to a post thumbnail

It sounds like you are trying to use get_permalink() on a URL. get_permalink() expects a post ID, not a URL. Try this:

add_filter( 'post_thumbnail_html', 'my_post_link_html', 10, 3 );
function my_post_link_html( $html, $post_id, $post_image_id ) {
    // Uncomment for debugging. This will replace the featured image with the debugging output. 
    // exit ( var_dump( $GLOBALS['ghostpool_affiliate_button_link'] ) ); 

    if ( $GLOBALS['ghostpool_affiliate_button_link'] ) {
        $affiliate_link = $GLOBALS['ghostpool_affiliate_button_link'];
        $affiliate_target = apply_filters( 'gp_affiliate_link_target', '' );

        $html="<a href="" . esc_url( $affiliate_link ) . '" rel="nofollow" . target="' . esc_attr( $affiliate_target ) . '">' . $html . '</a>';
    }

    return $html;
}