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

Phoenix bugfix for undefined outputFormat #1556

Merged
merged 1 commit into from
Nov 15, 2024

Conversation

cartermak
Copy link
Member

See #1555

Possible fix seems to work locally for me, but it's unclear whether this is a "bug" or whether I should fix something in my adaptation.

@mattdailis
Copy link
Collaborator

Tracking it back to the source - $outputFormat should be coming from here - and it seems to be designed to always be a list. I suppose that implies that the issue is indeed in SequenceEditor.svelte.

export const outputFormat = derived(
[sequenceAdaptation],
([$sequenceAdaptation]) => $sequenceAdaptation?.outputFormat ?? [],
);

Somehow outputFormats is ending up... undefined, right? Or is it null? Could this be a phasing/initialization issue?

@cartermak
Copy link
Member Author

Yes, an initialization issue is my best understanding.

It's initialized undefined:

let outputFormats: IOutputFormat[];

...and it seems to be nominally set by loadSequenceAdaptation, which seems to be called when parcel.sequence_adaptation_id changes...:

$: {
loadSequenceAdaptation(parcel?.sequence_adaptation_id);
}

...and my understanding is that, even though I don't define outputFormat in my adaptation, the adaptation should fall back to a default value: https://github.com/NASA-AMMOS/aerie-ui/blob/b99e9229b92ff9da1be7e37a9f5c2bf7ecbad7d4/src/stores/sequence-adaptation.ts#L68C58-L68C75

...which is SeqJson, as I'd hope:

outputFormat: [
{
fileExtension: 'json',
name: 'Seq JSON',
toOutputFormat: sequenceToSeqJson,
},
],

@cartermak
Copy link
Member Author

That's as far as I dug; I could keep reading through the source, but I expect a Phoenix dev would be better equipped to clarify design intent vs. current behavior.

@duranb
Copy link
Collaborator

duranb commented Nov 14, 2024

That's as far as I dug; I could keep reading through the source, but I expect a Phoenix dev would be better equipped to clarify design intent vs. current behavior.

It's intended that outputFormat is always defined, even if the user doesn't provide one in their adaptation explicitly. While adding a check prior to using the length does fix it, it only fixes what's affected and not the source. I think more investigation is needed into how it's being set to undefined if all code paths prior to this is supposedly setting it to at least an empty []

@duranb
Copy link
Collaborator

duranb commented Nov 14, 2024

@cartermak It looks like you're working off an older version of the codebase. Would you be able to pull in the latest and see if it's still occurring for you? (I don't think we explicitly had a fix for this)

@cartermak
Copy link
Member Author

@duranb thanks for that clarification. In this case, outputFormat is expected to be defined for a sequence adaptation, but outputFormats in the SequenceEditor component isn't initialized by default until loadSequenceAdaptation is called.

Re: codebase version, I can try on develop; I found the bug trying to get Clipper set up on 3.1.0, so I branched from the tag for now.

@mattdailis
Copy link
Collaborator

Would initializing it to the empty list count as addressing the root cause?

-   let outputFormats: IOutputFormat[]; 
+   let outputFormats: IOutputFormat[] = []; 

@cartermak
Copy link
Member Author

@duranb tested and I still see the behavior on develop. Looks like the only reason there's conflict is this change Cody made: v3.1.0...develop#diff-1329a1a0eea656e262443bf11e90d4a2988f6bb3c52b88ba6c2ca7b8fbacf2d3L229-R230

@mattdailis tried that and it works too, but I haven't scanned the code to see whether anything is expecting to find undefined instead of an empty array.

@duranb
Copy link
Collaborator

duranb commented Nov 14, 2024

@duranb thanks for that clarification. In this case, outputFormat is expected to be defined for a sequence adaptation, but outputFormats in the SequenceEditor component isn't initialized by default until loadSequenceAdaptation is called.

@cartermak Ohh. Got it. Now I see it. You're correct.

Would initializing it to the empty list count as addressing the root cause?

-   let outputFormats: IOutputFormat[]; 
+   let outputFormats: IOutputFormat[] = []; 

@mattdailis That would be a good fix!

@cohansen
Copy link
Contributor

Sorry I missed this whole conversation, yeah the thought was it should never be undefined if you're providing an adaptation but that still should be a valid code path.

outputFormats is derived from sequencing language adaptation, but
starts out as undefined. This commit protects any code that assumes
it's always a list.
@mattdailis mattdailis force-pushed the bugfix/3.1.0-phoenix-undefined-outputFormat branch from 210d9c8 to a6b6194 Compare November 15, 2024 21:46
@mattdailis mattdailis marked this pull request as ready for review November 15, 2024 21:46
@mattdailis mattdailis requested a review from a team as a code owner November 15, 2024 21:46
@mattdailis
Copy link
Collaborator

Pair-reviewed with @dandelany

@mattdailis mattdailis merged commit 563c9fc into develop Nov 15, 2024
5 checks passed
@mattdailis mattdailis deleted the bugfix/3.1.0-phoenix-undefined-outputFormat branch November 15, 2024 22:02
dandelany pushed a commit that referenced this pull request Nov 19, 2024
Initialize outputFormats to the empty list

outputFormats is derived from sequencing language adaptation, but
starts out as undefined. This commit protects any code that assumes
it's always a list.

Co-authored-by: Matthew Dailis <[email protected]>
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.

4 participants