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

Export with hishtory to JSON could not be imported as JSON #279

Closed
jmauro opened this issue Jan 7, 2025 · 3 comments
Closed

Export with hishtory to JSON could not be imported as JSON #279

jmauro opened this issue Jan 7, 2025 · 3 comments

Comments

@jmauro
Copy link

jmauro commented Jan 7, 2025

Hello,

When trying to export the hishtory for then importing it I have an import error:

# hishtory status -v
hiSHtory: v0.324
Enabled: true
Secret Key: XXXXXXXXXXXXXXXXXXXXXXXXXX
User ID: XXXXXXXXXXXXXXXXXX
Device ID: XXXXXXXXXXXXXXXX
Sync Mode: Enabled
Sync Status: Synced
Commit Hash: XXXXXXXXXXXXXXXXX
hishtory export-json > /tmp/export.json
# cat /aviatrix/hishtory.json | hishtory import-json
2025/01/07 01:00:49 hishtory v0.324 fatal error at github.com/ddworken/hishtory/client/cmd/import.go:46: cannot import history entries without a command, JSON line: "{\"command\":\"\",\"current_working_directory\":\"Unknown\",\"custom_columns\":null,\"end_time\":\"2024-06-25T14:12:52.195329787Z\",\"exit_code\":0,\"home_directory\":\"/root\",\"hostname\":\"3500f4725c42\",\"local_username\":\"root\",\"start_time\":\"2024-06-25T14:12:52.194329787Z\"}"

I would expect, at least, hishtory to ingest exported files created by itself.
Not a big deal, I just got rid of the empty command, but hishtory could have exported a file which doesn't violate it import requirements, don't you think?

Kind regards,
JM

@ddworken
Copy link
Owner

ddworken commented Jan 7, 2025

Thank you for this issue! This makes perfect sense and I 100% agree that this is a bug.

@dezza since you mentioned you were looking to contribute to hishtory, this could be a nice and easy first bug. It would just be a matter of updating export.go to filter out entries with where command is "". And then adding an integration test to TestExportJson in client_test.go would be good to. If you are interested, LMK, otherwise I'll send out a PR for this myself.

@dezza
Copy link

dezza commented Jan 7, 2025

Thank you for this issue! This makes perfect sense and I 100% agree that this is a bug.

@dezza since you mentioned you were looking to contribute to hishtory, this could be a nice and easy first bug. It would just be a matter of updating export.go to filter out entries with where command is "". And then adding an integration test to TestExportJson in client_test.go would be good to. If you are interested, LMK, otherwise I'll send out a PR for this myself.

I will stick to the other issue for now.

@ddworken
Copy link
Owner

Ok, this should be fixed now! Thanks again for reporting this.

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

No branches or pull requests

3 participants