Bug: onConfluenceSpace fails for personal spaces

Description:
The properties API from @forge/api incorrectly sanitizes space keys and rejects keys for personal spaces. On Cloud personal spaces are made up of a tilde followed by a bunch of digits, for example ~12345689 . The sanitization function uses this regex to sanitize space keys though: /^[A-Za-z0-9_\-]+$/

Steps to reproduce:

Call properties.onConfluenceSpace(spaceKey) with a spaceKey from a personal space.

Expected:
The properties API can handle personal spaces the same as any other space.

Actual:
The onConfluenceSpace call fails with this stack trace:

Error: Invalid context/property key
    at sanitizedKey (index.js:20321:15)
    at Object.onConfluenceSpace (index.js:20337:105)
    at Object.handleClick [as onClick] (index.js:8850:83)
    at index.js:8960:60
    at asyncMap (index.js:8942:30)
    at index.js:8963:35
    at asyncMap (index.js:8942:30)
    at index.js:9025:29
    at asyncMap (index.js:8942:30)
    at index.js:8963:35

Example code:

import ForgeUI, { render, Button, InlineDialog, ContentBylineItem, useProductContext } from '@forge/ui';
import { properties } from '@forge/api';

const App = () => {
    const context = useProductContext();
    const handleClick = () => properties.onConfluenceSpace(context.spaceKey).get('test-key');

    return (
        <InlineDialog>
            <Button
                text="Click me"
                onClick={handleClick}
            />
        </InlineDialog>
    );
};

export const run = render(
    <ContentBylineItem>
        <App/>
    </ContentBylineItem>
);

Hi @thomas2,

I have raised this internally. Thanks for raising :slight_smile:

1 Like