ampproject / ampproject/amphtml

Supplying parameters when calling `getTCData` gives an error

Open
#36,014 5 comments 0 reactions 1 assignee Claimed by @alanorozco View on GitHub
Component: amp-consent Stale Type: Bug
Dominant language
JavaScript
Stars
14.9k
Forks
4.1k
PR merge metrics
No merged PRs in 30d

Description

### Description

Adding the`exposesTcfAfpi="true"` attribute to an `` element causes the following error to be raised in the console.

```
[amp-consent] Unsupported parameter found in "tcfapiCall": 278
```

This appears to be because the call to [isValidTcfApiCall_](https://github.com/ampproject/amphtml/blob/f564b7ee3cd59972fe86c4edc3052db70852c6f0/extensions/amp-consent/0.1/tcf-api-command-manager.js#L281) logs an error as it is called with the following payload:

```
{ command: "getTCData", parameter: [278], version: 2 }
```

This throws an error because a [vendor supplies an id](https://github.com/InteractiveAdvertisingBureau/GDPR-Transparency-and-Consent-Framework/blob/master/TCFv2/IAB%20Tech%20Lab%20-%20CMP%20API%20v2.md#gettcdata) and [this check](https://github.com/ampproject/amphtml/blob/f564b7ee3cd59972fe86c4edc3052db70852c6f0/extensions/amp-consent/0.1/tcf-api-command-manager.js#L294-L297) disallows parameters for all commands except `REMOVE_EVENT_LISTENER`. It seems like it should be allowed to supply the optional vendor id when calling `getTCData` even if it is ignored.

### Reproduction Steps

Visit https://xenodochial-mestorf-c61695.netlify.app and open the console. You should see one of the following error messages:

```
[amp-consent] Unsupported parameter found in "tcfapiCall": 278
```

### Relevant Logs

```shell
[amp-consent] Unsupported parameter found in "tcfapiCall": 278
Fb @ log.js:232
g.error @ log.js:270
ec @ cdn.ampproject.org/r…mp-consent-0.1.js:2
W.handleTcfCommand @ cdn.ampproject.org/r…mp-consent-0.1.js:2
(anonymous) @ cdn.ampproject.org/r…mp-consent-0.1.js:2
```

### Browser(s) Affected

_No response_

### OS(s) Affected

_No response_

### Device(s) Affected

_No response_

### AMP Version Affected

2108280007001

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.