Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

EntityPath::from_str must parse the given string #1114

Merged
merged 1 commit into from
Feb 6, 2023

Conversation

teh-cmc
Copy link
Member

@teh-cmc teh-cmc commented Feb 6, 2023

This is a very dangerous and hard to track footgun:

    let a = EntityPath::from("null_demo/rect/0");
    let b = EntityPath::from(
        rerun::external::re_log_types::parse_entity_path("null_demo/rect/0").unwrap(),
    );
    dbg!(&a);
    dbg!(&b);
    dbg!(a == b);
[examples/api_demo/src/main.rs:158] &a = EntityPath(null_demo/rect/0)
[examples/api_demo/src/main.rs:159] &b = EntityPath(null_demo/rect/0)
[examples/api_demo/src/main.rs:160] a == b = false

It is made even more dangerous by the fact that some API will just take the EntityPath you give them as-is (e.g. send_path_op) while some will re-parse it behind the scene (e.g. log_arrow).
Consequently, the following will never work, even though everything looks like it's in the right place:

    // sim_time = 1
    MsgSender::new("null_demo/rect/0")
        .with_timepoint(sim_time(1 as _))
        .with_component(&[Rect2D::from_xywh(5.0, 5.0, 4.0, 4.0)])?
        .with_component(&[ColorRGBA::from([255, 0, 0, 255])])?
        .with_component(&[Label("Rect1".into())])?
        .send(session)?;
    MsgSender::new("null_demo/rect/1")
        .with_timepoint(sim_time(1 as _))
        .with_component(&[Rect2D::from_xywh(10.0, 5.0, 4.0, 4.0)])?
        .with_component(&[ColorRGBA::from([0, 255, 0, 255])])?
        .with_component(&[Label("Rect2".into())])?
        .send(session)?;

    // sim_time = 2
    log_cleared(session, &sim_time(2 as _), "null_demo/rect/0", false);

    // sim_time = 3
    log_cleared(session, &sim_time(3 as _), "null_demo/rect", true);

The event log looks right, except it just doesn't work:
image

@teh-cmc
Copy link
Member Author

teh-cmc commented Feb 6, 2023

cc @emilk you might want to have a look at this one

@teh-cmc teh-cmc merged commit 0a3e8bb into main Feb 6, 2023
@teh-cmc teh-cmc deleted the cmc/entity_path_footgun branch February 6, 2023 17:42
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.

2 participants