Closed Bug 1814767 Opened 2 years ago Closed 2 years ago

Can't use Rust reserved keywords in Event extra_keys as key names

Categories

(Data Platform and Tools :: Glean: SDK, defect)

defect

Tracking

(Not tracked)

RESOLVED DUPLICATE of bug 1800862

People

(Reporter: jteow, Unassigned)

References

Details

STR

Create an Event with extra_keys containing a property name with reserved keyword in the Rust language (e.g. type).

// metrics.yaml
example:
  ...
  type: event
  extra_keys:
    type:
        description: Lorem ipsum.
        type: string

Then, try to compile Firefox.

Result

The struct representing the extra properties will contain properties that will cause Rust compilation errors during the firefox-on-glean step. Should get the "expected identifier, found keyword type".

// metrics.rs
pub struct SomeExtra {
  pub type: Option<String>
}

Yeah, this is a known issue, see also bug 1800904.

Question:

  • Are you using the generated Rust API or the C++ or JavaScript API?
  • If using the Rust API, would you expect to use r#type in your code?
See Also: → 1800904

I'm using the Javascript API for Firefox Desktop. For now, I got Data Science to approve a property name change to unblock the story.

Might be sufficient just to say that limitation that in the documentation.

(In reply to James Teow [:jteow] from comment #2)

I'm using the Javascript API for Firefox Desktop. For now, I got Data Science to approve a property name change to unblock the story.

Might be sufficient just to say that limitation that in the documentation.

Thanks. Yeah, we'll have to figure out something here.

Status: NEW → RESOLVED
Closed: 2 years ago
Duplicate of bug: 1800862
Resolution: --- → DUPLICATE
You need to log in before you can comment on or make changes to this bug.