Skip to content

Operator's extra link button is disabled #43252

@mfatemipour

Description

@mfatemipour

Apache Airflow version

2.10.2

What happened?

When in get_link method I provide None, the button is enabled and when I provide link (internal link) it is disabled

What you think should happen instead?

In the following code, if url is empty or None, the result of isSanitised is True !
also if the url is internal then isSanitised is False (so internal url is not supported)

As a workaround for now I am providing a random non-rul string instead of None, and I replaced my internal url with absolute one (but I missed rendering my page in same window now)

https://github.com/apache/airflow/blob/2.10.2/airflow/www/static/js/dag/details/taskInstance/ExtraLinks.tsx

const isExternal = (url: string | null) =>
    url && /^(?:[a-z]+:)?\/\//.test(url);

  const isSanitised = (url: string | null) => {
    if (!url) {
      return true;
    }
    const urlRegex = /^(https?:)/i;
    return urlRegex.test(url);
  };

  return (
    <Box my={3}>
      <Text as="strong">Extra Links</Text>
      <Flex flexWrap="wrap" mt={3}>
        {links.map(({ name, url }) => (
          <Button
            key={name}
            as={Link}
            colorScheme="blue"
            href={url}
            isDisabled={!isSanitised(url)}
            target={isExternal(url) ? "_blank" : undefined}
            mr={2}
          >
            {name}
          </Button>
        ))}
      </Flex>
      <Divider my={2} />
    </Box>
  );
};

How to reproduce

  • Create a simple plugin with an OperatorLink
  • Return None in get_link() method of your OperatorLink
  • You can see the button in Details page of corresponding task is enalbed.

Operating System

Debian GNU/Linux 12 (bookworm)

Versions of Apache Airflow Providers

non related

Deployment

Docker-Compose

Deployment details

We are deploying on docker swarm

Anything else?

It works in 2.8.1
And It seems that internal url issue is fixed in main branch but None handling is not fixed.

Are you willing to submit PR?

  • Yes I am willing to submit a PR!

Code of Conduct

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions