Skip to content

The PMP resource key is the file name in the tag's URL - #240

Draft
jwrosewell wants to merge 4 commits into
feature/create-last-gfrom
docs/pmp-key-in-path
Draft

jwrosewell wants to merge 4 commits into
feature/create-last-gfrom
docs/pmp-key-in-path

Conversation

@jwrosewell

Copy link
Copy Markdown
Contributor

The Preference Management Platform reads its resource key from the URL path
and from nowhere else, so the pages that document it have to say so.

Stacked on feature/create-last-g.

What the pages now say

Before After
Loader api/v4/pmp api/v4/pmp/{resource}.js
Bundle api/v4/pmp/{name} api/v4/pmp/{resource}/{name}
The key data-resource-key the file name in the tag's own URL

That is the shape api/v4/{resource}.js and api/v4/{resource}.json
already take, so the PMP now reads like every other keyed endpoint.

Both tag snippets on the integration page, the complete tag and the
attribute table on the configuration page, and the load sequence diagram on
the index page all follow. data-resource-key is gone from the attribute
table, because it is not an attribute any more.

The integration page says plainly what the old shape was and that it is
answered 404 now. A reader arriving with a page that worked on an earlier
release needs to know why it stopped rather than be left to guess, and the
reason is worth stating, which is that two places to write one key meant a
page could carry one the service never saw and the refusal that followed was
invisible to the page.

Second commit, the naming

101 uses of "the platform" across eight pages become "the PMP". PMP is the
name, and it matters most here because these pages also talk about a consent
management platform, so a reader has to be able to tell which one a sentence
means.

What stays untouched:

  • "Consent management platform" and "Preference Management Platform",
    being the full names.
  • Every "your platform", "whose platform" and "that platform" on the
    consent management platform page, because those mean the reader's own
    platform and not this one.
  • The console message quoted on that page, because the client script really
    writes those words and the documentation has to match what a reader will
    see in their console.

One sentence on that page said "the platform itself may load later" about
the reader's own consent management platform. It names it now, because a
sentence that could be read either way is exactly what the naming rule is
for.

Four of the 101 were invisible to a plain search, because the two words sat
on separate lines. The files use CRLF line endings, so a multiline pattern
written with \n matches nothing and reports the page clean.

Checked

  • No em dash anywhere in the changed pages.
  • Line endings unchanged, so each diff is the lines that really changed.
  • Every @ref target in this repository is a @page label rather than
    heading text, so renaming the five headings that said "the Platform"
    breaks no link.
  • The repository's .utm-lint.json is { "mode": "forbid" } and nothing
    here adds a tagged link.

Has to move with it

The service change that makes this true, and the preference demo in
51Degrees/device-detection-dotnet-examples on branch
feature/pmp-key-in-path, whose fourteen page templates wrote the old
shape.

The loader is served at /api/v4/pmp/{resource}.js and each bundle at
/api/v4/pmp/{resource}/{name}, so the key is a path segment, the same
shape as every other keyed request, and data-resource-key is gone.

Both tag snippets, the attribute table and the load sequence diagram
follow. The integration page says plainly what the old shape was and that
it is answered 404 now, because a reader arriving with a working page
from an earlier release needs to know why it stopped rather than be left
to guess.
101 uses across eight pages, against the rule that PMP is the name and
"the platform" is not, which matters most here because these pages also
talk about a consent management platform and the reader has to be able to
tell which one a sentence means.

What stays. "Consent management platform" and "Preference Management
Platform" are untouched, being the full names. So is every "your
platform", "whose platform" and "that platform" in the consent management
platform page, because those mean the reader's own platform and not this
one. So is the console message quoted there, because the client script
really writes those words and the documentation has to match.

One line in that page said "the platform itself may load later" about the
reader's consent management platform, which now names it, because a
sentence that could be read either way is exactly what this rule is for.
… card wait starts as the PMP now does, and name the PMP, the Global Privacy Platform and the consent management platform where each is meant
The preview clones every API repo at the pull request's base branch, so a
documentation change can be previewed against the API change it describes.
Where the repo has no branch of that name the clone fails outright and the
whole preview fails with it.

That happens every time a documentation branch is raised against another
documentation branch, because the base name is then a documentation branch
name and it means nothing in an API repo. The preview reports

    fatal: Remote branch <name> not found in upstream origin

and stops at the first repo in the map, so none of the documentation is
built and the failure says nothing about the documentation itself.

Each repo is now asked whether it has the branch, with git ls-remote, and
cloned at main where it does not. A repo that does have it is still cloned
at it, which is the behaviour the preview is there for, and an examples
repo is asked separately from the repo it sits inside because the two can
differ. The chosen ref is printed for each, so a preview that built against
main rather than a paired branch says so in its own log.

git ls-remote exits zero with no output for a branch that is not there, so
the emptiness of the output is the test rather than the exit code, which
leaves a genuinely unreachable repo still failing the run.
@jwrosewell

Copy link
Copy Markdown
Contributor Author

The Preview failure was the preview script, not this documentation

What failed

Preview Documentation failed after 35 seconds, before building anything:

##[group]Cloning API docs
Cloning into '/home/runner/work/documentation/documentation/apis/pipeline-dotnet'...
fatal: Remote branch feature/create-last-g not found in upstream origin
NativeCommandExitException: ci/generate-documentation.ps1:33
Program "git" ended with non-zero exit code: 128

Why

ci/generate-documentation.ps1 clones every API repository at the pull
request's base branch, so that a documentation change can be previewed
against the API change it describes:

$ref = $env:GITHUB_BASE_REF ? $env:GITHUB_BASE_REF : $env:GITHUB_REF_NAME ? $env:GITHUB_REF_NAME : 'main'
...
git clone -b $ref --depth=1 ... "https://github.com/$owner/$repo.git" "$apis/$repo"

That works while the base branch is main, or has a counterpart of the same
name in the API repository. This pull request is based on another
documentation branch, feature/create-last-g, and no API repository has a
branch of that name, so the very first clone failed and, with
$ErrorActionPreference = "Stop", took the whole run with it. Nothing was
built and the failure said nothing about the documentation.

Any documentation branch raised on another documentation branch hits this,
which is why it has not been seen before. It is not specific to this change.

The fix

3e75a8a80 asks each repository whether it actually has the branch and falls
back to main where it does not:

function Resolve-Ref($url, $preferred) {
    if ($preferred -eq 'main') {
        return 'main'
    }
    $found = git ls-remote --heads $url $preferred
    return $found ? $preferred : 'main'
}

Three things worth noting about it.

A repository that does have the branch is still cloned at it, so the paired
branch behaviour the preview exists for is unchanged. An examples repository
is asked separately from the repository it sits inside, because the two can
differ. git ls-remote exits zero with no output for a branch that is not
there, so the emptiness of the output is the test rather than the exit code,
which leaves a genuinely unreachable repository still failing the run rather
than silently falling back.

The chosen ref is printed for each repository, so a preview that built
against main rather than a paired branch says so in its own log.

Verified

Checked against the real remotes before committing. An absent branch resolves
to main, feat/51did-add on pipeline-dotnet resolves to itself, and
fix/pmp-key-in-path on device-detection-dotnet-examples resolves to
itself, so a paired branch is still picked up.

In CI, run
35069927530
now passes in 3m14s and prints one line per repository, all resolving to
main as expected for this base branch:

pipeline-dotnet at main
pipeline-java at main
...
rust at main

Both checks on this pull request are now green.

Outstanding

The fix is a CI change sitting on a documentation branch, which is untidy. It
is one self-contained file and can be lifted onto its own pull request into
main if that is preferred, at the cost of this pull request staying red
until that lands and comes back down the stack.

@github-actions

Copy link
Copy Markdown
Contributor

Documentation preview 👀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant